Created
July 10, 2014 22:19
-
-
Save zootella/f6c3d3a790c3bdb09369 to your computer and use it in GitHub Desktop.
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
//make something available to the file from within a function in the file | |
//make sure it doesn't affect what's available in files that require this one | |
var color1 = "red"; | |
var color2 = "orange"; | |
//and we want to set two more colors, using the function below | |
function setColors() { | |
var extraColors = {color3:"yellow", color4:"green"}; | |
for (color in extraColors) { | |
//module[color] = extraColors[color];//module doesn't work! | |
global[color] = extraColors[color];//global works, but i hope it doesn't mess up files that require this one | |
} | |
} | |
setColors(); | |
//now let's see what worked | |
console.log("color1 is " + color1); | |
console.log("color2 is " + color2); | |
console.log("color3 is " + color3); | |
console.log("color4 is " + color4); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment