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
  • 37,241
  • 25
  • 195
  • 267
Ben Avnon
  • 1,681
  • 2
  • 13
  • 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
  • 25,338
  • 7
  • 55
  • 68