I am creating a object using Object.create
and I want to add properties to it.
> var o = Object.create({});
undefined
> Object.defineProp
Only when both writable and configurable are false, "Cannot redefine property" will happen.
If writable or configurable is true, the error will disappear.
"use strict"
var obj = {};
Object.defineProperty(obj, "name",
{
value: "Fundebug",
writable: false,
configurable: false
})
Object.defineProperty(obj, "name",
{
value: "云麒"
}) // “Uncaught TypeError: Cannot redefine property: name”
Therefore, jdphenix and Jonathan are not exactly correct.