Underscore.JS - create method
Syntax
_.create(prototype, props)
create method create a new object with given prototype and attaches the props as own properties. See the below example:
Example
var _ = require('underscore');
function SetName(name) {
this.name = name;
}
var result = _.create(SetName.prototype, {name: "Moe"});
console.log(result);
Save the above program in tester.js. Run the following command to execute this program.
Command
\>node tester.js
Output
SetName { name: 'Moe' }
underscorejs_mapping_objects.htm
Advertisements