Using Multiple Parameters with Functions part 3

Multiple Parameters



When calling the function, provide the arguments in the same order in which you defined them.
function sayHello(name, age) {
document.write( name + " is " + age + " years old.");
}

sayHello("John", 20)
//Outputs "John is 20 years old."
Try It Yourself

If you pass more arguments than are defined, they will be assigned to an arraycalled arguments. They can be used like this: arguments[0], arguments[1], etc.

Comments

Popular posts from this blog

Introducing object part 3

Comparison Operators part 2

Module 2