object 对象

var deng = {

        name : 'deng',

        age : 23,

        sex : 'male',

        health : 123,

        smoke : function () { console.log('I am smoking!!!    cool!!!'); this.health ++;  },

         drink : function () { console.log('I am drinking!!!  cool!!!'); this.health --;}

}

注意:  每个属性使用逗号隔开,  name : 'chen',   name = 'chen', 注意区别。

deng.smoke       函数引用

deng.smoke()     函数执行

扫描二维码关注公众号,回复: 1021781 查看本文章

this 是在一个方法里,所以指的这个方法。

删除属性:   delete deng.sex /delete+空格+deng.sex

猜你喜欢

转载自blog.csdn.net/qq_42139305/article/details/80202218