1

If I have:

var myKey = "This_is_my_key"
var myObj = {"This_is_my_key" : true}

How do I access myObj at myKey?

Cœur
  • 34,719
  • 24
  • 185
  • 251
Ben Avnon
  • 1,521
  • 2
  • 12
  • 13

1 Answers1

2

why don't you try this

var myKey = "This_is_my_key";
var myValue = true;

myObj[myKey] = myValue;

This is same as

myObj.This_is_my_key=true
Mritunjay
  • 24,184
  • 7
  • 51
  • 67