I see a couple pull requests fixing the same issue with array iteration when the array prototype has been extended (#2, #7), so I thought I'd open another one :-)
I think this fix is simplest - just use a regular for loop instead of for..in. The trouble with for..in is it doesn't guarantee iteration order, and it also picks up inherited properties. For these reasons, it is generally not recommended to use for..in for iterating over an array.
I see the other pull requests addressed this issue either by either checking the type to ensure it's not a function, or using hasOwnProperty, but I think this method is the simplest - it's what a for loop is for!
I see a couple pull requests fixing the same issue with array iteration when the array prototype has been extended (#2, #7), so I thought I'd open another one :-)
I think this fix is simplest - just use a regular for loop instead of for..in. The trouble with for..in is it doesn't guarantee iteration order, and it also picks up inherited properties. For these reasons, it is generally not recommended to use for..in for iterating over an array.
I see the other pull requests addressed this issue either by either checking the type to ensure it's not a function, or using hasOwnProperty, but I think this method is the simplest - it's what a for loop is for!