Created
May 14, 2015 02:59
-
-
Save jaspervalero/5d36a97002e6580c4343 to your computer and use it in GitHub Desktop.
var Overwrite Example
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
| 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