Possible Duplicate:
Does JavaScript Guarantee Object Property Order?
I would like to know how I can insert a JSON object property at a specific position? Let's assume this Javascript object:
var data = {
0: 'lorem',
1: 'dolor sit',
2: 'consectetuer'
}
I have an ID and a string, like:
var id = 6;
var str = 'adipiscing';
Now, I would like to insert the id
between 0
and 1
(for example) and it should be like:
data = {
0: 'lorem',
6: 'adipiscing',
1: 'dolor sit',
2: 'consectetuer'
}
How can I do this? Is there any jQuery solution for this?