Is it possible to add a key value pair to an existing JavaScript associative array using a variable as the key? I need this for JSON encoding and prefer a simple solution over using plugins or frameworks.
ary.push({name: val});
In the above code snippet, ary
represents a new array, name
is the variable containing the key, and val
holds the value of the entry.
I am implementing this within a loop using jQuery to iterate through form fields.