来源:hongdada
var foo = {}; Object.defineProperty(foo, "x", { value: 10, writable: true, // 即{ReadOnly} = false enumerable: false, // 即{DontEnum} = true configurable: true // 即{DontDelete} = false }); console.log(foo.x); // 10 console.dir(foo.x); // 通过descriptor获取特性集attributes var desc = Object.getOwnPropertyDescriptor(foo, "x"); console.dir(desc);