Javascript code should never iterate an array with:
for (var k in array)
because that type of iteration iterates all enumerable properties of the array object including things added as enumerable by third party libraries (shame on that library). It does not iterate just array elements. If you are using code that is doing things as bad as that, then I'd be very concerned about the quality of that code.
To iterate just array elements the code should use one of these:
for (var k = 0; k < array.length; k++)
array.forEach(fn)
Or in ES6:
for (var item of array)
If you are trying to add new methods to the Array prototype and you want them to not be picked up for a for (x in y) loop, then you need to add them as non-enumerable using Object.defineProperty() or Object.defineProperties(). When defining them this way, enumerable defaults to false and they will not get picked up the the for/in loop.
Object.defineProperties(Array.prototype, {
last: {value: function() { return this[this.length - 1]; }},
first: {value: function() { return this[0]; }}
});