parameters are also local variables
We can declare local variables and give them initial values in parameter list of function definition. So we have another way to create local variables.
This commit is contained in:
parent
2027939238
commit
6a432df33b
1 changed files with 1 additions and 1 deletions
|
@ -273,7 +273,7 @@ We covered three ways to create a function in JavaScript:
|
|||
```
|
||||
|
||||
|
||||
- Functions may have local variables: those declared inside its body. Such variables are only visible inside the function.
|
||||
- Functions may have local variables: those declared inside its body or its parameter list. Such variables are only visible inside the function.
|
||||
- Parameters can have default values: `function sum(a = 1, b = 2) {...}`.
|
||||
- Functions always return something. If there's no `return` statement, then the result is `undefined`.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue