I've never worked with prototype, and maybe I don't even understand how it works, so here I am.
I'm trying to change how .push() works in javascript: it adds the parameter as the last element, but I want it to add the parameter in the first position.
Here is my non-working guess:
Array.prototype.push() = function(e){
var x = [e];
return x.concat(this);
}
Sorry for the breathtaking mistakes I probably made :)
Disclaimer: I'm just trying to understand how to modify native methods. Why is everybody so scared?
.unshift()method adds new elements to the start of the array - any reason why you're not using it instead of trying to redefine.push()?.push()already does (at least, it doesn't overwrite whatever is already in the last position, it appends after it, but...).