You can override any built-in function by just re-declaring it. parseFloat = function(a){ alert(a) }; Now parseFloat(3) will alert 3.
I know that delete
is a keyword in JavaScript. So I have this code (for example):
var user = {
create : function () {
// Create a user account
},
delete : function () {
// Delete a user account
}
};
The above works (barring older versions of IE), so my question is - is it a good idea. Obviously the call user.delete();
is much clearer to someone utilizing the code than something like user.delete_one();
Obviously keywords are important, but on a case by case basis is it alright (granted I don't need legacy IE support) to use this method, or is there a better solution?
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