我對JS的obj順序問題:如何獲得JS對象的正確順序?
當我定義:
var objJSON = {};
objJSON[31] = '123'; ------------- (1)
objJSON[23] = '456'; ------------- (2)
,並提醒對象:
alert(JSON.stringify(objJSON, null, 4));
它顯示:
"
{
"23":"456",
"31":"123"
}
"
I would like to get the object by the order of inserting:
"
{
"31":"123",
"23":"456"
}
"
如何這樣做?