Underscore.JS - functions 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');

var student = {
   name: 'Sam',
   age: 10,
   print: function(){
      console.log(name +", " + age);
   }   
}

var result = _.functions(student);
console.log(result);

Save the above program in tester.js. Run the following command to execute this program.

Command

\>node tester.js

Output

[ 'print' ]
underscorejs_mapping_objects.htm
Advertisements