I encountered this code snippet that has left me puzzled:
Array.remove = function(array, from, to) {
var rest = array.slice((to || from) + 1 || array.length);
array.length = from < 0 ? array.length + from : from;
return array.push.apply(array, rest);
};
What does it signify? Am I potentially overriding the default remove()
method of my web browser? Will this work on older browsers as well?
Adding to the confusion is how the function is invoked:
Array.remove(foo, bar);
There are only two actual arguments provided while the function expects three formal parameters. How does the function determine which ones to use?