create source npm

_.create(prototype, [properties])

Creates an object that inherits from the given prototype object. If a properties object is provided its own enumerable properties are assigned to the created object.

Arguments

  1. prototype (Object)

    The object to inherit from.

  2. [properties] (Object)

    The properties to assign to the object.

Returns (Object)

Returns the new object.

Example

function Shape() {
  this.x = 0;
  this.y = 0;
}

function Circle() {
  Shape.call(this);
}

Circle.prototype = _.create(Shape.prototype, {
  'constructor': Circle
});

var circle = new Circle;
circle instanceof Circle;
// => true

circle instanceof Shape;
// => true