- Lodash - Home
- Lodash - Overview
- Lodash - Environment Setup
- Lodash - Array
- Lodash - Collection
- Lodash - Date
- Lodash - Function
- Lodash - Lang
- Lodash - Math
- Lodash - Number
- Lodash - Object
- Lodash - Seq
- Lodash - String
- Lodash - Util
- Lodash - Properties
- Lodash - Methods
- Lodash Useful Resources
- Lodash - Quick Guide
- Lodash - Useful Resources
- Lodash - Discussion
Lodash - create method
Syntax
_.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.
Arguments
prototype (Object) − The object to inherit from.
[properties] (Object) − The properties to assign to the object.
Output
(Object) − Returns the new object.
Example
var _ = require('lodash');
function Shape() {
this.x = 0;
this.y = 0;
}
function Circle() {
Shape.call(this);
}
Circle.prototype = _.create(Shape.prototype, {
'constructor': Circle
});
var circle = new Circle;
console.log(circle instanceof Circle);
console.log(circle instanceof Shape);
Save the above program in tester.js. Run the following command to execute this program.
Command
\>node tester.js
Output
true true
lodash_object.htm
Advertisements