Skip to content

Instantly share code, notes, and snippets.

@pawiromitchel
Created April 20, 2021 14:48
Show Gist options
  • Save pawiromitchel/bad9fdca1c10034425817ec04881a81e to your computer and use it in GitHub Desktop.
Save pawiromitchel/bad9fdca1c10034425817ec04881a81e to your computer and use it in GitHub Desktop.
Dynamisch object call based on a given string
var array1 = [1,2,3];
var array2 = [4,5,6];
// eval https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval
console.log(eval('array'+'2'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment