Is there any performance difference using the slice() method with or without the last argument [end]?
Example:
var m = ['But', 'Will', 'It', 'Blend', 'Question'];
var r = m.slice(1,3);
OR
var r = m.slice(2);
PS: not the result as it is, but the performance issue only.
If you take a look at the implementation https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/slice you will see that if the second argument is not sent then it uses the array length so no, I think they are the same.
Array.prototype.slice = function(begin, end) {
// IE < 9 gets unhappy with an undefined end argument
end = (typeof end !== 'undefined') ? end : this.length;
.....................................
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With