This is a
playground to test code. It runs a full
Node.js environment and already has all of
npm’s 400,000 packages pre-installed, including
create with all
npm packages installed. Try it out:
This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.
create is a module for node.js (and someday the browser too) that implements the
.create() functions on the rest of the native data types in
Object.create(). So why not
Function.create()? Well that's exactly what this module adds functionality for.
In essense, this gives you a clean interface for subclassing the native classes,
and also gets all the same benefits that
Object.create() gives you, like setting
the prototype at creation-time, and being able to pass an object descriptor in to
define additional properties.
When you require the module, you invoke it as a function and pass in any native
classes you want extended with a
.create() function. This can be done with
any of the native types.
$ npm install create
Let's make a subclass of
Array, that includes a
This module depends on the writability of the
__proto__ property on objects.
From a browser standpoint, this module will only work in browsers where that is
__proto__ MAY be changed). In node this will always work.