4.17.11
3.10.1
2.4.2
1.3.1

_.create(prototype, [properties])

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

Since

2.3.0

Arguments

argument
prototype
[properties]
type
Object
Object
description
The object to inherit from.
The properties to assign to the object.

Returns

(array)

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
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