Ecmascript objects are mainly divided into two categories::
1. Local objects, that is, objects independent of the host environment.
Object fuction array string Boolean number date RegEx error evalerror rangeerror referenceerror typeerror urlerror syntaxerror
A special type of local object is built-in objects: Global and math.
Ecmascript does not exist in independent functions. All function pairs must rely on objects.
Global Objects have functions such as encodeurl (), decodeurl (), and eval.
Note: Each defined global variable points to the global object, and the window object also points to the global object,Global variables are applied to allCodeShared, so it is easy to cause name conflicts between different pages. To write code, you should reduce the definition of global variables..
FunctionSum (x, y ){//Antipattern: Implied globalResult = x +Y;ReturnResult ;}
The result in the above function is defined as a global variable.
FunctionSum (x, y ){VaRResult = x +Y;ReturnResult ;}
View code
Use VaR to define result as a local variable.
In addition, the global variables created through var Declaration are different from those implicitly created through var declaration:
The global variables created through var declaration cannot be deleted.
The globally variables created by implicit deletion can be deleted.
Returns true or false after the delete operator operation to identify whether the deletion is successful.
2. Host Object
There are two main categories: BOM and Dom.