Overriding the alert method.
I was kinda surprised this worked- but, now I see it work, I can't figure why it wouldn't work.
function alert() {
for (var i=0, total = 0, len=arguments.length;
i<len; i++) {
console.log( arguments[i] );
}
}
alert( 'well, would be surprised if this works','as is','Consider me surprised!' );
I know it never is a good idea to extend (or overwrite like this) default methods. So just consider this a show-and-tell type of thing.
A shorter version would of course look like:
function alert( msg ) {
console.log( msg );
}Written by Kotrotsos
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Javascript
Authors
Related Tags
#javascript
Did you know?
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#