0

How can I create an object like this in JS since public and private are reserved words

keyObject = {
    public : {
        iv: "123",
        key: "123"
    },   
    private : {
        key: "123"
   }
}
pawel
  • 35,827
  • 7
  • 56
  • 53
Jacob
  • 3,580
  • 22
  • 82
  • 146

2 Answers2

1

Quote the keys, like this:

var keyObject = {
    "public" : {
        iv: "123",
        key: "123"
    },
    "private" : {
        key: "123"
    }
}

http://jsfiddle.net/5tUXy/

pawel
  • 35,827
  • 7
  • 56
  • 53
0

you can define keys as strings

keyObject {
    'public': {
        iv: "123",
        key: "123"
    },
    'private': {
        key: "123"
    }
}
John Smith
  • 615
  • 4
  • 15