object-create-x
Sham for Object.create
module.exports
⇒ boolean
⏏
This method method creates a new object with the specified prototype object and properties.
Kind: Exported member
Returns: boolean
- A new object with the specified prototype object and properties.
Throws:
TypeError
If the properties parameter isn't null or an object.
Param | Type | Description |
---|---|---|
prototype | * |
The object which should be the prototype of the newly-created object. |
[properties] | * |
If specified and not undefined, an object whose enumerable own properties (that is, those properties defined upon itself and not enumerable properties along its prototype chain) specify property descriptors to be added to the newly-created object, with the corresponding property names. |
Example
; // Shape - superclass { thisx = 0; thisy = 0;} // superclass methodShapeprototype { thisx += x; thisy += y; console;}; // Rectangle - subclass { Shape; // call super constructor.} // subclass extends superclassRectangleprototype = ;Rectangleprototypeconstructor = Rectangle; const rect = ; console; // trueconsole; // truerect; // Outputs, 'Shape moved.'