Objects are special variables in JS, it could contain all of variables types, including function.
an simple example with their names.
how to show the specific property value, 2 ways:
it is also fine to use retrieve variable,
How to add new property and property value,
Notice: we do not need *var* here. So result is here :
Above is simple object. Let’s have a little bit complex object.
Function expression can be stored in a variable, and the variable can be used as a function :
Those functions are anonymous function (function without name). Because they do not need names, they are invoked using the variable name.
(Learned from w3schools JS Function parts)
Generally, how to call a function expression ?
We need a new variable “z” to store the function result, and call the function variable name which is “calcuateAge”and pass parameter”yearOfBirth” and “1992”.
However when this function expression is in object, how to call it ?
Now I got a new idea,
I will use keyword “this”,
What is “this” in our example ?