资讯

Scope in JavaScript refers to context (or portion) of the code which determines the accessibility (visibility) of variables. In JavaScript, we have two types of scope, local , and global.
Pre-standard C++ had quirky scope behavior similar to your first example - variables declared specifically in a for loop's initializer statement remained in scope through the end of the block.
Tips for naming JavaScript variables Dynamic typing and JavaScript variables How to work with string variables What you need to know about variable scope What is a user-defined variable in JavaScript?