Reputation: 61
Sorry JS is not my language :-(
I should build such a json value:
var input = { 'to': { '[email protected]' : 'Jhon Doe' }
I have read a ton of docs but i am stuck whith:
var userEmail = '[email protected]'
var input = { 'to': { userEmail : 'Jhon Doe' }}
console.log(input);
// result-> userEmail: "Jhon Doe"
so, how can push a JS variable into json ?
Upvotes: 1
Views: 54
Reputation: 3826
var input = { 'to': { [userEmail] : 'Jhon Doe' }}
[userEmail]
will turn to the value of userEmail
.
Alternatively:
var input = { 'to': {} };
input[userEmail] = 'Jhon Doe';
Upvotes: 2