[Gukulkan]

Learn, develop, play.

Functions in JavaScript (js)

To create function in javascript we should write just:


function hello() {
}

For example lets call Alert with text Hello World :


function hello() {
alert("Hello World");
}

And call this function:


hello();

If you need to send some parameters in function, just write like this:


function hello(s) {
alert(s);
}
hello("Hello World");

We call this function with parameters and you can see “Hello World” in alert again.