bestiejs / json3

A JSON polyfill. No longer maintained.
https://bestiejs.github.io/json3
Other
1.02k stars 150 forks source link

`walk` should not use `splice` when removing an array element #10

Closed ghost closed 12 years ago

ghost commented 12 years ago

walk should use the delete operator when removing elements from arrays, instead of Array#splice.

Expected:

JSON.parse("[1, 2, 3]", function (key, value) {
  if (typeof value == "object" && value) {
    return value;
  }
}).length == 3;

Actual:

JSON.parse("[1, 2, 3]", function (key, value) {
  if (typeof value == "object" && value) {
    return value;
  }
}).length == 0;