JavaScript attribute names and values

(I) Property name

var obj = new Object();

Adding attributes to object

 

⑴ property name:

          - the name of the object attribute is not mandatory to comply with the specification identifier

                What a mess names can be used

         - but we still try to do it in accordance with the use of standardized identifiers

Example: obj.name = "Lin"

 

⑵ If you want to use a special attribute name not be used. The way to operate

   We need another way: Syntax: Object [ "attribute name"] = attribute value

   Also you need to read this way

   Example:

 

 

using [] This form attribute to operate, more flexible;

    You may be transferred directly from a [] in the variables , so that the variable value is the number which will read the attribute

 

(Ii) property values

⑴JS object attribute value may be any type of data, an object may be even

Example ⑵ any data type:

 

Examples of the attribute value of the object ⑶JS object:

 

Operators ㈢in

⑴ can check whether an object containing properties specified by the operator

   If it returns true, not false returns

syntax: "property name" in the object

⑶ examples are as follows:

 

 

Guess you like

Origin www.cnblogs.com/shihaiying/p/11992821.html