Warning: Attempt to read property "ID" on bool in /www/wwwroot/129.28.78.18/wp-content/themes/storeys-pro/wbc/components/og_schema/wb_og_schema.php on line 471

Warning: Attempt to read property "display_name" on bool in /www/wwwroot/129.28.78.18/wp-content/themes/storeys-pro/wbc/components/og_schema/wb_og_schema.php on line 480

Warning: Attempt to read property "display_name" on bool in /www/wwwroot/129.28.78.18/wp-content/themes/storeys-pro/wbc/components/og_schema/wb_og_schema.php on line 487

Warning: Attempt to read property "description" on bool in /www/wwwroot/129.28.78.18/wp-content/themes/storeys-pro/wbc/components/og_schema/wb_og_schema.php on line 489

Warning: Attempt to read property "ID" on bool in /www/wwwroot/129.28.78.18/wp-content/themes/storeys-pro/wbc/components/og_schema/wb_og_schema.php on line 493

9-17添加对象 四大属性

添加对象

var chiled=Object.creat(obj,{

​ 四大属性

​ age:{

​ value:20,

​ writable:false //是否修改当前属性 ture可以修改 false不能

​ enumerable:false //控制是否可以用for in 遍历属性

​ configurable:false //控制:1.是否可删除该属性 2.是可修改前两个属性

​ }

})

var change={

​ name:"一颗",

​ sex:"男",

​ }

// Object.preventExtensions(change) //防扩展 :禁止添加新属性,相当于将对象的extensible:false

//开起防扩展不能扩展了 是false

​ console.log(Object.isExtensible(change)) //可以扩展 true

​ Object.seal(change) //在兼具防扩展同时,又进一步禁止删除属性。但是,属性值还是可以修改的。在防扩展同时,禁止删除现有属性,相当于将每个属性的configurable:false,其他属性在修改特性时,不必反复修改configurable:false

​ console.log(Object.isSealed(change)) //检查是否密封 //密封了是true 没密封是false

​ Object.freeze(change)

​ console.log(Object.isFrozen(change)) //冻了是true 没冻是false

​ change.age=22

​ console.log(change)

今日份保镖给我弄懵了

评论留言