This is happening because you are using for..in
on an array. You shouldn't be doing that.
When you added Array.prototype.xintsum
, you added a xintsum
property to every array. So, what happened was, that your for
loop iterated over that property of your array.
The value of this property is a function. When you pass a function to .text()
, jQuery will call it like this:
v.call(ele, index text);
It's setting this
to the element. And well, DOMElements don't have .reduce
functions.
You need to loop like this:
for(var i = 0; i < some_array.length; i++){
var v = some_array[i];
}