Is this a valid way to enable the alert function to accept multiple arguments?
-
function shout() { for (var i = 0; i < arguments.length; i++) { alert.apply(this, [arguments[i]]); } } shout('Hello','World'); //> alerts 'hello' and 'world' subsequently
-
Answer:
With tools like JSFiddle, it's hard to really say that you don't have time to run the code: http://jsfiddle.net/nPpGN/
Andy LeMay at Quora Visit the source
Other answers
!function(original) { window.alert = function() { [].slice.call(arguments, 0).map(original); }; }(alert); ...assuming you are in a modern browser where you can use Array.prototype.map
Makinde Adeagbo
Related Q & A:
- Is there a neat way to do contextual logging in a concurrent system?Best solution by Stack Overflow
- Do I need to have a box for my 2 12'' JL audio subs or can they be mounted a different way?Best solution by Yahoo! Answers
- Does Drake Club has a valid number?Best solution by Yahoo! Answers
- What is a good way to advertise enexpensively for a small business? It is handyman work?Best solution by Yahoo! Answers
- Can I transit through UK on a valid tourist visa?Best solution by Quora
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.