js how to operate within the object properties and methods

  • eg:var  str = "age"

console.log (obj.str); later point to note here do not add variable syntax, because he would attribute as a variable name, should write like this

console.log(obj[str];

  • Note: use "" wrap if the key object contains special symbols, creating this attribute; use [] can not be used simultaneously call.

eg: "alfjaf @ # & gjs": Hsiao Ming

  • By: adding new properties and methods for an object

Object attribute name = value;

  • Delete: Delete the object in a property

delete the object name. attribute name, delete if successful, returns true, false otherwise

I, was res = delete p1.name;

console.log(res); 

  • Change: modify the value of a property

Object Name = name of the new property value;

 

Guess you like

Origin www.cnblogs.com/1998Archer/p/12544387.html