Skip to content

Instantly share code, notes, and snippets.

@marcveens
Last active March 22, 2017 14:50
Show Gist options
  • Select an option

  • Save marcveens/b7ed5f6b64636ace06d2dc89b92eb63a to your computer and use it in GitHub Desktop.

Select an option

Save marcveens/b7ed5f6b64636ace06d2dc89b92eb63a to your computer and use it in GitHub Desktop.
Chaining methods
;(function () {
function utils() { }
utils.prototype.customString = function(str) {
this.value = str;
return this;
};
utils.prototype.toLower = function() {
this.value = this.value.toLowerCase();
return this;
};
utils.prototype.toValue = function() {
return this.value;
};
var line = new utils().customString('SomeText').toLower().toValue();
console.log(line);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment