I'm trying to add a key value pair to an existing javascript associative array. The key needs to be a variable. This is for JSON encoding. I realize there are many plugins and frameworks for this, but I want a simple answer.
ary.push({name: val});
where ary
is a new array, name
is a variable containing the key, val
is the value of this entry.
I'm doing this in a jQuery
loop that iterates through form fields.