course content

Course Content

Introduction to JavaScript

ArgumentsArguments

Arguments are function variables that you can use inside function only:

Also, if you name the arguments the same name 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 (all arguments lose value).

Arguments are received sequentially:

Unfilled arguments will receive the value undefined and will not be displayed in any way, in particular, redundant arguments will not be used in any way.

The function receives literals as arguments. Variables outside the function are not changed. An argument is an independent value inside a function:

The numb argument changed in the example above, and the global variable a remained at 15.

Note

This does not work for arrays because the array contains a reference to some data. This reference passes to the function (the space pointed to by the reference changes). This will be studied in the OOP in JavaScript course.

Section 6.

Chapter 4