js object, creating methods, instanceof, null destroy objects, traverse the object properties

JavaScript objects

Having the same or similar properties is an abstract object class. Abstract objects, that is, Class of concrete (instantiate) an object is called

Creation Method

json method

var zhangsan={属性名:属性值,属性名2:属性值2,属性名3:属性值3,......};

Constructor

function person(){this.tall=180;this.sex='nv'};
var lisi=new poson();

Object Methods

var new Object();

Deleting objects

delete 对象.属性;

Access to the object properties and methods

Access Properties

引用值.属性
引用值[“属性”]

Access Methods

引用值.属性();
引用值[“属性”]()

Destroy the object

对象=null;

instanceof

For detecting whether an object is an instance of a constructor

Prototype object

A property constructor

Traversal object properties

for (var i in Objct){
Object[i]
}

Guess you like

Origin www.cnblogs.com/liuxuhui/p/12157157.html