How to create a key value array in jquery?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to create a key value array in jquery?

codeinsects
Hi all, Recently I was working on a jquery project and I have to create a key value array using jquery and Javascript. I tried so many ways but the last way which works for me was something below :

var formData = {
abc : qty,
xyz: 'string',
form_id : form_id,
product_nid : nodeId
};
Its working fine. BUt initially I have written the product_nid as product-nid ( hyphen instead of underscore ). It started giving me an error.
I just want to know why hyphens are not allowed in the jquery javascript array key.
Thanks in advance.
Loading...