javascript - 物件資料和存取器可配置和可枚舉特性預設的不是true嗎?
大家讲道理
大家讲道理 2017-06-26 10:58:19
0
3
652
雷雷
雷雷
大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

全部回覆(3)
黄舟

物件預設的可設定屬性和可列舉屬性是true吧

這個沒錯,但是這個指的是不使用defineProperty或者defineProperties的時候,使用它們的時候,那兩個屬性默認為false

Enumerable properties are those properties whose internal [[Enumerable]] flag is set to true, which is the default for properties created via simple assignment or via a aperion initiionalizers (Funced sdefed sdefault or via a aperty initiion​​ion s ]] to false).

defineProperties

漂亮男人

這個API手冊裡面有說明,預設為false。

ringa_lee

紅包書上說的是,對於直接在物件上定義的屬性,他們預設值為true;類似這樣,
`

var book = {
    a: 1   //默认configurable就是ture
}
//以下不同
Object.defineProperty(book,{
    b:{
        value: 5 //为配置configurable,则默认false
    },
    c:{
        value:4,
        configurable: true //有配置,为true
    }
})

`
我抽出了我的紅包書,對,他就是說的直接定義在物件上的屬性,configurable特性預設為true,不行,你可以輸出'a','b','c'的configurable值

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板