views:

67

answers:

1

Hello,

I am having an object with variables named [0...10] and few variables with normal names. I delete one of them with delete obj[3]. Then there is a gap in this sequence. I want to arrange them now from [0...10]. My first though is to loop through and rename keys(variables). How I can do it?

P.S. - Object cannot change its structure or be converted to an array to use splice()..

+1  A: 

So why haven't you tried your first thought?

delete obj[k]
for ( var i = k; i < N - 1; ++i) {
   obj[i]=obj[i+1];
}
delete obj[N];
Artem Barger
overheated at the end of the work i guess..
faya