Mitch Mitch - 2 months ago 6
jQuery Question

How do I set names.x

I want to know how to set x names in a option variable.

var names = {};


and then set
names.{username from event (e.user.username)} = 1;

Answer

You can use bracket notation to pass variable as key.

var username = 'Lorem';
var names = {};

names[username] = 1;
console.log(names)