Last active
February 19, 2019 19:22
-
-
Save jasp402/d4bb8ab5037d368fdb58077e86177de7 to your computer and use it in GitHub Desktop.
VarDinamically
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
/** | |
ESTA FUNCION CREA VARIABLES DINAMICAMENTE BASADO EN UN OBJETO. | |
**/ | |
let etc = { name: 'foobar', city: 'xyz', company: 'companyName' }; | |
Object.keys(etc).forEach(key=>{return eval(`${key.toUpperCase()}='${etc[`${key}`]}'`)}); | |
console.log(NAME) //foobar | |
console.log(CITY) //xyz | |
console.log(COMPANY) //companyName |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment