Home >Web Front-end >JS Tutorial >What is a js object? What are the js object types? Summary of js object types
This article brings you what is a js object? What are the js object types? The summary of js object types has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
Objects are the representation of nouns (such as people, things, things) in demand scenarios in the program
In JavaScript, in addition to string, number, Boolean, null, and undefined , other data are objects, such as arrays, dates and even functions;
ECMA-262 definition:
An unordered collection of attributes, each attribute stores an Primitive value, object or function
An object is an array of values in no particular order
An object is a special data type that can contain multiple members
The members of an object are divided into two types: properties and methods
Property:
-encapsulates the data of the object and represents the value related to the object
-Object name.Attribute name
Method (Method):
-Encapsulates the behavior of the object, indicating the behavior that the object can perform or can complete Function
-Object name.Method name
Object = Property Method
Object type in JS
1. Built-in objects/native objects: refers to the 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 the standard, these objects are compatible with browsers. The sexual problem is not too big
String, Number, Boolean Array, Date, RegExp, Math Error Object, Function Global
2. Host object: refers to the JavaScript running environment ( The objects provided by browsers 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 resolved by the writer Note
There are three 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 colons. Separate with commas
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
Related recommendations:
js(Dom) object and jquery object mutual conversion
Introduction to JS objects_js object-oriented
The above is the detailed content of What is a js object? What are the js object types? Summary of js object types. For more information, please follow other related articles on the PHP Chinese website!