For example using Underscore library, the following code works:
var myobject = {};
_.extend(myobject, {
method: 'demo'
});
Here, myobject.method prints demo. But the following example does not work, myboject.method is undefined, when I set the value of method to be a function instead of a string:
var myobject = {};
_.extend(myobject, {
method: function() {
return 'demo'
});
});