Skip to content

Instantly share code, notes, and snippets.

@dperrymorrow
Last active August 29, 2015 14:12
Show Gist options
  • Save dperrymorrow/600742b04877389c4357 to your computer and use it in GitHub Desktop.
Save dperrymorrow/600742b04877389c4357 to your computer and use it in GitHub Desktop.
how to reference variables properly in Javascript
// 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