In JS, there is no block-level scope, and the function is the smallest scope, so that all variables can be placed in the top-level declaration of the function. At the same time, you also need to pay attention to the for loop, which is different from the usage method in Java. Even within the body of a for loop or if statement, the variables declared are at the function level.
The function will extend the scope of the scope, which also derives the concept of closure. For details, you should refer to "JS Advanced Programming", which explains it in more detail.
Dynamic objects based on prototype inheritance
JS is not object-oriented like Java, but it can be inherited through prototype. However, using prototype directly will cause all derived objects to share the attributes or methods of the prototype. Therefore, when writing object-oriented code, you should pay attention to such issues.
Statement:
All resources on this website are contributed and published by netizens, or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this website are for learning and reference only. Please do not use them for commercial purposes, otherwise you will be responsible for all consequences incurred! If there is any infringement, please contact us to delete and remove it. Contact information: admin@php.cn