afeld / backbone-nested

A plugin to make Backbone.js keep track of nested attributes - looking for maintainers! https://github.com/afeld/backbone-nested/issues/157
https://afeld.github.com/backbone-nested/
MIT License
444 stars 83 forks source link

lo-dash and sparse arrays converting previously set indexes as holes #98

Closed mohitmayank closed 4 years ago

mohitmayank commented 10 years ago

with lo-dash setting arrays with object notations or objects with numeric indexes or sparse arrays makes holes in array

if i am setting following keys

set('base.child.2.test', 100); or set('base.child[2].test', 100); //sparce array

where child already have a 0 index. it gets converted to undefined.

starting - base = { child : [ { test : 50 } ] }; model.set('base', base);

model.set('base.child.2.test', 100);

the result is

base = { child : [ undefined, undefined, { test : 100 } ] };

This problem appears when using lo-dash instead of underscore.

gkatsev commented 10 years ago

I'm not sure that's a problem. In js, when you set a high index on an array, you get holes.