Skip to content

Instantly share code, notes, and snippets.

@jaspervalero
Created May 14, 2015 02:59
Show Gist options
  • Select an option

  • Save jaspervalero/5d36a97002e6580c4343 to your computer and use it in GitHub Desktop.

Select an option

Save jaspervalero/5d36a97002e6580c4343 to your computer and use it in GitHub Desktop.
var Overwrite Example
var gamertag = 'TheAwesomeOne0110', // Set default gamer tag
gamers = [{
gamertag: 'SomeGamer1',
email: '[email protected]'
}, {
gamertag: 'GrumpyTrollolol',
email: '[email protected]'
}];
console.log( 'Before:', gamertag ); // TheAwesomeOne0110
for ( var i = 0; i < gamers.length; i++ ) {
var gamertag = gamers[ i ].gamertag;
console.log( 'Gamertag:', gamertag );
}
// Default gamer tag was accidentally changed in the loop
console.log( 'After:', gamertag ); // GrumpyTrollolol = last value set in loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment