0
Javascript object keys
var userName = "someName"; var userEmail = "aname@some.thing"; var dataObj = { userName : userEmail } // I need this // dataObj should be { "someName" : "aname@some.thing" }
5 Answers
+ 5
well then u would have to do it like this:
dataObj[userName] = userEmail
+ 1
var dataObj = {}
dataObj["someName"] = "aname@some.thing"
console.log(dataObj["someName"])
Have a look to this
+ 1
@maf thanks .
it worked!!
0
äžčâšă©Ú©ć»Ÿ I can't directly give the values and I need to use the variable