This question has already been answered:
How to add a variable value to an object and not a variable name?
I get {"tempIndex":"hello"} but I would like {"1":"hello"} .
var index = ["1","2"] var names = ["hello","dude"] var tempIndex = index[0] var tempName = names[0] var obj = {} obj.tempIndex = tempName document.write(JSON.stringify(obj))