After adding a method to the Array prototype, some other, unrelated script breaks.
- [Opera] Unhandled Error: 'this.reduce' is not a function
- [Firefox] TypeError: this.reduce is not a function
The method itself works ([1,2,3].xintsum()
outputs 6
as expected).
// adding a function to the Array prototype
Array.prototype.xintsum = function() { return this.reduce(function(old, add) {return old + add;}, 0); };
// accessing the array in a way that worked before
$(document).ready(function (){
var some_array = [];
for (head_n in some_array) {
var v = some_array[head_n];
$('<th></th>').text(v);
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>