work
This commit is contained in:
parent
28d3b85a1a
commit
73ce6f8a24
2 changed files with 3 additions and 1 deletions
|
@ -1,4 +1,6 @@
|
|||
|
||||
# Function in if
|
||||
|
||||
Look at the code. What will be result of the call at the last line?
|
||||
|
||||
```js run
|
||||
|
|
|
@ -346,7 +346,7 @@ But properties like `counter.count` have nothing in common with function variabl
|
|||
|
||||
Which approach is better?
|
||||
|
||||
The main difference is that if the value of `count` lives in a variable, then an external code is unable to access it. Only the nested function may modify it.
|
||||
The main difference is that if the value of `count` lives in a variable, then an external code is unable to access it. Only the nested function may modify it. Such variables are sometimes called *private* (to the function).
|
||||
|
||||
And if it's bound to function, then such thing is possible:
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue