Lets say the Array prototype has been augmented with some helper function:
Array.prototype.doSomething = function() { ... }
When I log out a simple array into the console ...
console.dir([1,2,3]);
... I get:
Array [3]
0: 1
1: 2
2: 3
length: 3
__proto__: Array[0]
doSomething: function()
everything looks fine so far.
But as soon as I deep clone the array using $.extend (deep clone because my actual data is more complex - an object with arrays as properties, but it happens in any case) ...
$.extend(true, [], [1,2,3]);
I suddenly get:
Array [3]
0: 1
1: 2
2: 3
doSomething: function() // ???
length: 3
__proto__: Array[0]
doSomething: function()
It looks like the prototype method has been added as an actual item of the array instance.
Does JQuery.extend not test for hasOwnProperty() before copying, or am I doing something wrong here?