Portable Object.create that is not a shim and drops the verbose property descriptor syntax.
npm install create-object --save
You can also use Duo, Bower or download the files manually.
var create = require('create-object')
var point = create({
type: 'Point',
coordinates: [-0.127758, 51.507351],
valueOf: function () { return this.coordinates }
})
point
//=> {}
point.valueOf()
//=> [ -0.127758, 51.507351 ]
var create = require('create-object')
var geo = create({}, {
coordinates: [-0.127758, 51.507351]
})
geo
//=> { coordinates: [ -0.127758, 51.507351 ] }
- True prototypal inheritance.
- Your code does not need to bother with constructors or the
new
keyword. - Fields and methods on the prototype are non-enumerable.
- Works in all JS engines (including old IEs like IE8).
- Does not shim/sham
Object.create
. - Ignores verbose ES5 property descriptor syntax.
prototype: (Object)
The object which should be the prototype of the newly-created object.properties: (Object)
Key-values which should be copied to the newly-created object.
(Object)
New object with the specified prototype object including any copied properties.
SEE: contributing.md