Home  >  Article  >  Web Front-end  >  What objects does javascript support?

What objects does javascript support?

青灯夜游
青灯夜游Original
2021-09-07 16:17:503198browse

JavaScript supports three types of objects: 1. Built-in objects, including String, Number, Boolean, Array, Date, RegExp, Math, Error, Object, Function, and Global; 2. Browser objects; 3. Auto Define objects.

What objects does javascript support?

The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.

JavaScript objects are collections of related properties and methods. JavaScript supports three types of objects: built-in objects (native objects), browser objects, and custom objects.

1. JavaScript built-in objects:

refers to the predefined objects of the JavaScript language itself, defined in the ECMAScript standard and used by all browser manufacturers To provide specific implementation, due to the unification of standards, the browser compatibility problem of these objects is not too big

String, Number, Boolean, Array, Date, RegExp, Math, Error, Object, Function, Global

2. JavaScript Window - Browser Object:

The Browser Object Model (BOM) allows JavaScript to talk to the browser .

There is no official standard for the Browser Object Model (BOM). Modern browsers have implemented (almost) the same methods and properties for JavaScript interaction, so it is often mentioned as a method and property of the BOM.

Methods and properties are often considered BOM because modern browsers have implemented (almost) the same methods and properties for JavaScript interactivity.

Window object:

All browsers support the window object. It represents the browser window.

1), the window object is the top-level object;

2), the window object has 6 major attributes, including: document, frames, history, location, navigator, screen, these 6 major attributes The properties themselves are also objects;

3), the document properties under the window object are also objects, and there are also five major properties under the document (anchors, forms, images, links, location) that are also objects.

3. JavaScript custom objects:

Through JavaScript, you can define and create your own objects.

There are two different ways to create a new object:

  • Define and create an instance of the object

  • Use functions to define object, and then create a new object instance

Create a custom object:

var person=new Object();
person.firstname="John";
person.lastname="Doe";
person.age=50;
person.eyecolor="blue"; 
document.write(person.firstname + " is " + person.age + " years old.");

[Recommended learning:javascript advanced tutorial

The above is the detailed content of What objects does javascript support?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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