hankknight
asked on
JavaScript: Add item to BEGINNING of object (NOT ARRAY)
How can I add an item to the beginning of an object? This adds it to the end:
var obj = {"O":"-","R":"-","L":"-","D":"-"};
obj.W="-";
alert(JSON.stringify(obj));
I was advised to use unshift() however that seems to only work with arrays. This must stay an object, and the desired order must be maintained.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.