A full-expressive javascript
JavaScript is a weakly typed language. When you define a variable, you do not need to declare its type.
JavaScript type: Primitive type: Numeric type, Boolean, String type.
The type of the object, the type of function that contains the executable code, the empty type, and the undefined type.
JS in the function is a class citizen. Can be stored in variables, as parameters, as a return value, can be dynamically constructed.
anonymous function: function () {} to create functions without names
Functions to be executed immediately: (function ()
{var a=10;alert (a*10);} ) ();
Pass parameter: (function (A, B)
{alert (a*b);} ) (10,5);
An important use of anonymous functions is to create closures. Closures are a protected variable space that is generated by inline functions.
JavaScript has a function scope and cannot access internal variables outside the function.
The scope of JavaScript is lexical in nature. A variable is run in the scope it defines, not in the scope it is called.
var globv
(function () {
var a=10;
var b=20;
GLOBV =function () {
return a*b;}
})();
GLOBV ();
JS Design Pattern Notes