Skip to content

Instantly share code, notes, and snippets.

@akari0624
Last active July 15, 2017 19:23
Show Gist options
  • Save akari0624/1c3dead4a02299ae828315f6d12c93a9 to your computer and use it in GitHub Desktop.
Save akari0624/1c3dead4a02299ae828315f6d12c93a9 to your computer and use it in GitHub Desktop.
dollarSignCanDoAggregate.js
(function(global) {
global.$ = function(initNum) {
var aggregate = initNum;
return {
add: function(plusNum) {
aggregate += plusNum;
return this;
},
result: function() {
return aggregate;
}
};
}
}
)(window);
// for test
console.log($(1).add(2).add(3).add(4).result());
console.log($(2).add(5).result());
console.log($(7).add(2).add(100).add(9).result());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment