Skip to content

Instantly share code, notes, and snippets.

@mosfet1kg
Created January 24, 2017 18:04
Show Gist options
  • Save mosfet1kg/02c92c5e16542d243525e4d77c9ece59 to your computer and use it in GitHub Desktop.
Save mosfet1kg/02c92c5e16542d243525e4d77c9ece59 to your computer and use it in GitHub Desktop.
stringbuilder.js
function aaa(){
var str='';
return {
aaaa: function(l){
str+=l;
//console.log(str);
return this;
},
bbbb: function(){
console.log(str);
}
}
}
var t1 = new aaa();
t1.aaaa('hello');
t1.aaaa('world');
t1.aaaa('nice').aaaa('meet').aaaa('you');
t1.bbbb();
var t2 = new aaa();
t2.aaaa('hello1');
t2.aaaa('world1');
t2.aaaa('nice1').aaaa('meet1').aaaa('you1');
t2.bbbb();
@mosfet1kg
Copy link
Author

gbchoiui-MacBook-Pro:aws gbchoi$ node mytest.js
helloworldnicemeetyou
hello1world1nice1meet1you1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment