View chain2.js
var chain = (function() { | |
var count = 0; | |
function Inner() { | |
var self = this; | |
self.funcA = function(num) { count += num; return self; } | |
self.funcB = function() { count += 2; return self; } | |
self.ok = function() { var result = count; count=0; return result; } | |
} | |
return new Inner(); | |
}()); |
View chain1.js
var _ = require('underscore'); | |
function MyClass() { | |
this.prop1 = {}; | |
this.prop2 = {}; | |
this.prop3 = {}; | |
} | |
MyClass.prototype.func1 = function (obj) { | |
var self = this; | |
_.extend(self.prop1, obj); |