Home > front end >  JavaScript object
JavaScript object

Time:09-21

Knowledge:
1, object: see the value of the as long as it's not String characters, Number Number, Boolean, Boolean, Null Null values, Undefined Undefined these five, as an object,
Object belongs to a kind of compound data types, multiple different data types can be stored in the object attribute object classification:
1. The built-in objects: object, defined by the ES can be used in any ES the implementation of the
For example: Math String Number Bolean Function Object...
2. Host objects: object, provided by the js environment mainly supplied with the browser object, such as: BOM DOM object
3. Custom object: developers to define object
2, create the object: use the new key tone with the function, the constructor constructor is specially used to create the object function

For the object to add attributes:

Get object attribute value of

Modify the object property values

Delete the object attribute

Development: object attribute name is not forced to obey the rules of the identifier, any name can be, but are not allowed to use here, of our own definition to use must comply with the rules of identifiers
The In operator: through the In operator can check whether an object containing the specified attribute, if have return true, not false;
Grammar: "attribute name" in object

3, the basic data types and the reference data type
Basic data types: string number Boolean...
Reference data type: the object
JS variables are stored in the stack memory: the basic value of the type of data stored in the stack memory directly, value between is independent and modify a will not affect the other variables, the reference data class
Type is stored in the heap memory, each to create a new object, will appear a new space in the heap memory, variable to hold the object memory address, if the two variable to hold the
Is the same object references, when one of the through variables change properties, another would also be affected.
Basic data types: independent value, will not change because one of the variables change

Reference data type:

4, the object literal: when creating objects, directly on the specified object attributes in the
Grammar: {1 1: attribute values, the property name 2: attribute values 2,... }
Attribute name can be in quotes, it is recommended that do not add, if you use some special attribute name must be in quotes
Attribute name and attribute value is a set of key/value pair, the property name and use ":" colon connection between attribute values, each key value to use ", "between commas, if there is no
after a key/value pairOther key/value pair, you don't write ", "comma the

  • Related