Actually the argument you pass to function is pass by value
this means that even when you change the argument value it doesn't reflect to actual value...
Here, from w3Schools - JavaScript Function Parameters
Arguments are Passed by Value
The parameters, in a function call, are the function's arguments.
JavaScript arguments are passed by value: The function only gets to
know the values, not the argument's locations.
If a function changes an argument's value, it does not change the
parameter's original value.
Changes to arguments are not visible (reflected) outside the function.
Objects are Passed by Reference
In JavaScript, object references are values.
Because of this, objects will behave like they are passed by
reference:
If a function changes an object property, it changes the original
value.
Changes to object properties are visible (reflected) outside the
function
This from mdn - function deceleration | Thanks @Ivar
Primitive parameters (such as a number) are passed to functions by value; the value is >passed to the function, but if the function changes the value of the parameter, this change is not reflected globally or in the calling function.
If you pass an object (i.e. a non-primitive value, such as Array or a user-defined object) as >a parameter and the function changes the object's properties, that change is visible outside the function