Course Content
Introduction to JavaScript
4. Conditional Statements
Introduction to JavaScript
Arguments
Arguments are function variables that you can use only inside the function:
Also, if you name the arguments the same as the variables outside the function, the function will use the arguments instead of the variables:
Note
When the function finishes execution, its space disappears, and all arguments lose their values.
Arguments are received sequentially:
Unfilled arguments will receive the value undefined
and will not be displayed in any way. Redundant arguments will not be used:
The function receives values as arguments. Variables outside the function remain unchanged. An argument is an independent value inside a function:
Note
This does not work the same way for arrays because an array contains a reference to some data. This reference is passed to the function, so changes inside the function affect the data outside. This will be studied in the "OOP in JavaScript" course.
Everything was clear?