Home > Web Front-end > JS Tutorial > body text

An overview of objects in Javascript

黄舟
Release: 2017-08-13 10:35:01
Original
1402 people have browsed it

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:

1. Global object

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;

2. Javascript’s global objects

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.

2.1. The core global object of Javascript:

##1Value attributeNaN, Infinity, Undefined...##2342.2. Readability and writeability of global objects:
Serial number Category Chestnut
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...

Whether it is the core global object of Javascript or the global object expanded by the host environment; developers can access it at any time Call; the difference is:

1. The core global object defined in ECMAScript is overritable, but not enumerable, that is:

Writeable=true,Enumerable=false
2. 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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!