I'm using Backbone, but I feel this is more of a general javascript syntax question.
How can I add a method inside a method (or a function inside a function) and call them by chaining both?
var myModel = Backbone.Model.extend({
method1: function(x){
method2: function(y){
return x*y;
}
}
// or perhaps
method1: function(x){
{
method2: function(y){
x = x*y;
}
}
return x;
}
});
var mymodel = new myModel();
mymodel.method1(3).method2(5); // outputs 15