Home >Web Front-end >JS Tutorial >An overview of objects in Javascript
I believe that front-end developers already have a very good understanding of DOM and BOM objects. These two objects are not only introductory concepts, but also the most exposed concepts in daily development; at the same time, Javascript, one of the necessary knowledge for front-end development, due to It has a high degree of flexibility. Many students adhere to the concept of learning whatever they encounter and constantly improve their knowledge bit by bit. This is also one of the only ways for individuals to improve their skills; however, I personally prefer to grasp the overall situation. Guidance and daily accumulation are used as a means to improve.
In short, the best method is the method that suits you. Let’s get to the point:
Global object: In the host environment, itself and all its properties can be accessed anywhere in the program and at any time; if There is only one global object, and the global object is also the root node object;
Root node object: All attributes and methods are mounted under the root node object, which facilitates developers to set attributes. , method search; its disadvantage is that the call is cumbersome;
Global object: different attributes and methods are mounted under multiple node objects. The advantage is that the call is convenient and fast; the disadvantage is also that Java The language is criticized for being disordered, and you don’t know where to look for it when using it;
DOM and BOM objects. The current star NodeJS has a unique The global object, all other properties and methods are subordinate to the node object or its sub-node objects; such as DOM's html
, BOM's window
, NodeJS's global
;
For the convenience of developers, Javascript sets many methods and properties as global objects/properties, so Javascript does not have a so-called unique root node object;
The global object of Javascript depends on whether it depends on the host. The environment is divided into two categories:
- Core objects: ECMAScript Global Object, these objects already exist before the program is executed (default instantiation);
- Objects in the host environment: Global objects provided by the host environment/ Functions are commonly set by browsers and restrict developers from rewriting, such as: setTimeout, location, etc.
Serial number | Category | Chestnut |
---|---|---|
Value attribute | NaN, Infinity, Undefined... | |
Function attributes | eval(), parseInt(), isNaN(), decodeURI( ).... | |
Constructor (class) properties | Object, Array, Function, String, Boolean, Number, Date, RegExp, Error, RangeError, SyntaxError... | |
Others (similar to static classes in JAVA) | Math, JSON... |
Writeable=true,Enumerable=false2. Global objects set by the host environment (mainly browsers) are generally not allowed to be overridden
The above is the detailed content of An overview of objects in Javascript. For more information, please follow other related articles on the PHP Chinese website!