js创建对象
//創(chuàng)建對(duì)象
var chenhao = Object.create(null);?
//設(shè)置一個(gè)屬性
?Object.defineProperty( chenhao,'name', { value:? 'Chen Hao',writable:???? true,configurable: true,enumerable:?? true });?
//設(shè)置多個(gè)屬性
Object.defineProperties( chenhao,{'email'? : { value:? 'haoel@hotmail.com',writable:???? true,configurable: true,enumerable:?? true },'website': { value: 'http://coolshell.cn',writable:???? true,configurable: true,enumerable:?? true }});下面就說說這些屬性配置是什么意思。
-
writable:這個(gè)屬性的值是否可以改。
-
configurable:這個(gè)屬性的配置是否可以改。
-
enumerable:這個(gè)屬性是否能在for…in循環(huán)中遍歷出來或在Object.keys中列舉出來。
-
value:屬性值。
-
get()/set(_value):get和set訪問器。
總結(jié)
- 上一篇: 长城风骏5四驱1996ml是什么意思
- 下一篇: 长城举报比亚迪,真相是什么