Reading Notes for JavaScript proficiency (1)

Source: Internet
Author: User

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 ();
}());

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.