Are the JavaScript code snippets given below some sort of function declaration? If not can someone please give an overview of what they are?
some_func = function
The first example creates a global variable (if a local variable of that name doesn't already exist) called some_func
, and assigns a function to it, so that some_func()
may be invoked.
The second example is a function declaration inside an object. it assigns a function as the value of the show
property of an object:
var myObj = {
propString: "abc",
propFunction: function() { alert('test'); }
};
myObj.propFunction();