Skip to content

Instantly share code, notes, and snippets.

@finalight
Created July 5, 2016 03:43
Show Gist options
  • Save finalight/6bb38e9b377c0804baf4178608e8657e to your computer and use it in GitHub Desktop.
Save finalight/6bb38e9b377c0804baf4178608e8657e to your computer and use it in GitHub Desktop.
JKJpoJ
var celebsArr = [
{id: 1, name: '1'},
{id: 2, name: '2'},
{id: 3, name: '3'}
]
for (var i =0; i< celebsArr.length; i++){
celebsArr[i]['name'] = function(){
return 'hehe ' + i;
}
}
console.log(celebsArr[0].name());
console.log(celebsArr[1].name());
console.log(celebsArr[2].name());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment