arguments

Christian Harms's picture

In-depth guide to javascript functions

You already know how to define or assign functions directly, use multi parameter arguments in anonymous calls and know all the different variants of the function-constructor? Then you won't find anything new about the subtle differences in using functions in JavaScript.

The work title of this article was "Different ways to define JavaScript functions". Some code examples look quite similar but the differences can be important. While I am explaining the different ways to define JavaScript functions, you can test the code directly: install the firebug plugin and use the JavaScript console to play interactively below the article.

Function Statement

In the first example here I define a function to wrap the "window.alert"-function to open the default javascript popup-Message box:

  1. function hello(msg) {
  2.   alert(msg);
  3. }
Read more

Syndicate content