Last active
August 29, 2015 14:12
-
-
Save dperrymorrow/600742b04877389c4357 to your computer and use it in GitHub Desktop.
how to reference variables properly in Javascript
This file contains 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
// there is no reason to ever do this. I think PHP folks do this | |
window["myVariable"]; | |
// why not just do this | |
window.myVariable; | |
// save the first for when it's actually a variable | |
var foo = "someVarName"; | |
window[foo]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment