0

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 Answer 1

2

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];
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.