Last active
December 15, 2015 13:19
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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