Skip to content

Instantly share code, notes, and snippets.

Daniel Lewis BSc (Hons) danday74

View GitHub Profile
@danday74
danday74 / chain2.js
Created Feb 6, 2016
JavaScript chaining 2
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();
}());
@danday74
danday74 / chain1.js
Last active Feb 6, 2016
JavaScript chaining 1
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);
You can’t perform that action at this time.