Skip to content

Instantly share code, notes, and snippets.

View danday74's full-sized avatar

Daniel Lewis BSc (Hons) danday74

  • Angular Consultant
  • Guildford
View GitHub Profile
@danday74
danday74 / chain2.js
Created February 6, 2016 23:55
JavaScript chaining 2
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 February 6, 2016 23:54
JavaScript chaining 1
var _ = require('underscore');
function MyClass() {
this.prop1 = {};
this.prop2 = {};
this.prop3 = {};
}
MyClass.prototype.func1 = function (obj) {
var self = this;
_.extend(self.prop1, obj);