The translation of "Pro JavaScript tech" is available.
An object is a collection of attributes, similar to the hash table structure in other languages. Hashtable is created based on the hash function and uses a data dictionary such as a key/value pair as the storage format (formatting ). For example, the syntax structure of block struct in CSS (stacked style sheet) is similar to that of block struct.
The following is an example of code that directly assigns values to the "reflection" mechanism during runtime:
Code
VaR testcase = {
};
Testcase ['I'] = 0;
Testcase ['run'] = function (){
Return this. I;
}
Console. Log (testcase. Run ());
This is similar to the enumeration method of the hash list to the point of completely identical...
Everything in Javascript is an object. The second chapter is the most important one in this book.
Function overloading: The function parameters are pseudo arrays and the type check is used. If no parameter is provided, the parameter must be of the 'undefined' type. Both functions can be overloaded.
Scope:
Code
(Function (){
VaR getstr = function (){
VaR str1 = 'local variable ';
};
})();
Javascript scopes are only related to functions. The closure is related to the scope:
Code
(Function (){
VaR str1 = 'I love Javascript .';
VaR getstr = function (str2 ){
Return function () {console. Log (str1 + str2 );};
};
S = getstr ('Me too .')
S ();
}());