Home >Web Front-end >JS Tutorial >What is the object type of javascript
The object types of JavaScript are: 1. Built-in objects/native objects, predefined objects; 2. Host objects, including BOM objects and DOM objects; 3. Custom objects, objects created by users.
The object is the representation of nouns (such as people, things, things) in the demand scenario in the program
In JavaScript, in addition to string, Except for number, Boolean, null, and undefined, other data are objects, such as arrays, dates, and even functions;
ECMA-262 definition:
Attributes Unordered collection, each attribute stores a primitive value, object or function
Object is an array of values in no specific order
Object is a special data type that can contain multiple members
The members of the object are divided into two types: properties and methods
Property (Property):
-encapsulates the object Data, representing the value related to the object
-Object name. Attribute name
Method (Method):
-Encapsulating the behavior of the object, representing The behavior that the object can perform or the function that can be completed
-Object name.Method name
Object = Property + Method
Object type in JS
1 .Built-in objects/native objects: refers to objects predefined by the JavaScript language itself. It is defined in the ECMAScript standard and is provided by all browser manufacturers. Due to the unification of standards, browser compatibility issues with these objects do not exist. Too big
String, Number, Boolean Array, Date, RegExp, Math Error Object, Function Global
2. Host object: refers to the JavaScript running environment (i.e. browser ) are implemented by browser manufacturers. There were major compatibility issues in the early days. Currently, some of the main objects are compatible with most browsers; they are divided into the following two categories
(1) BOM object: Browser Object Model
Window, Navigator, Screen, History, Location
(2) DOM object: Document Object Model
Document, Anchor, Area , Base, Body, Button, Canvas, Event, Frame, Frameset, IFrame, Image, Link, Meta, Style, Form, Input Button, Input CheckBox, Input File, Input Hidden, Input Password, Input Radio, Input Reset, Input Submit , Input Text, Option, Select, Textare, Table, TableCell, TableRow
3. Custom object: refers to the object created by the user. Compatibility issues need to be paid attention to by the writer
There are 3 types of custom objects to create:
(1) Object direct quantity; a mapping table composed of name/value pairs. The name and value are separated by colons, and the name/value pairs are separated by commas. Separate
var obj1 = {}; var obj2 = {x:0,y:0}; var obj3 = {name:‘Mary’,age:18}
(2) new Object(); create system objects, create universal objects, create custom objects (custom constructors)
var obj1 = new Array; var obj2 = new Date();
(3) function object template
[Recommended learning: javascript advanced tutorial]
The above is the detailed content of What is the object type of javascript. For more information, please follow other related articles on the PHP Chinese website!