Skip to content

Instantly share code, notes, and snippets.

@arthurbarros
Last active December 15, 2015 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arthurbarros/5266720 to your computer and use it in GitHub Desktop.
Save arthurbarros/5266720 to your computer and use it in GitHub Desktop.
[solved] javascript: strange behavior // The problem that was that concat() dosen't change the value of the array, it returns the two arrays joined
function Foo(){
this.baz = [];
this.set = function(bar){
this.baz = this.baz.join(bar);
return this;
}
}
foo = new Foo();
foo.set({'a':123}).set({'b':321});
console.log(foo.baz);
// [ ] --empty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment