I found in the docs that you can create an plain object like this:
var y = {
name: "Pete",
age: 15
};
However, I would like to add name and value dynamically to it, for example if we have something like:
<input type="text" name="$dynamicName" id="myinput">
That I can create an object like this:
var y = {
name: "Pete",
$('#myinput).attr('name'): $('#myinput).val(),
};
But this will throw an error:
SyntaxError: missing : after property id
How can I use $('#myinput).attr('name')
as a name of a plain object?