Object.create works differently in Nodejs compared to FireFox.
Assume an object like so:
objDef = {
prop1: "Property 1"
}
obj = {
prop2: "Property 2"
}
var testObj = Object.create(obj, objDef);
The above javascript works perfectly in Mozilla. It basically uses the second argument passed to Object.create to set default values.
But this does not work in Node. The error I get is TypeError: Property description must be an object: true
.
How can I get this to work in Node? I want to basically create an Object with a default value.
The second parameter should map property names to property descriptors, which are to be objects.
See the example shown at the MDN:
You could solve by using something like this:
objDef = {
prop1: {
value: "Property 1"
}
}