Skip to content

Instantly share code, notes, and snippets.

@uptownhr
Created February 17, 2015 02:53
Show Gist options
  • Select an option

  • Save uptownhr/7055f7ef988a4ec9f244 to your computer and use it in GitHub Desktop.

Select an option

Save uptownhr/7055f7ef988a4ec9f244 to your computer and use it in GitHub Desktop.
js array filter clone
File Edit Options Buffers Tools Javascript Help
var test =[{a:1},{a:2},{a:3}];
exist = test.filter( function(itme){
return itme.a == 3
})
console.log(exist) //outputs a:3
exist.a = 99;
console.log(test); //outputs a:1, a:2, a:3
test.forEach( function(item){
item.a = 99;
})
console.log(test); //outputs a:99, a:99, a:99
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment