_.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
prototype
(Object): The object to inherit from.[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;// => truecircle instanceof Shape;// => true
当前内容版权归 lodash.com 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 lodash.com .