Update article.md

This commit is contained in:
totize 2019-01-27 16:06:20 +01:00 committed by GitHub
parent 028b80cf9d
commit 0eede58712
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -153,7 +153,7 @@ alert( `Called ${sayHi.counter} times` ); // Called 2 times
```warn header="A property is not a variable" ```warn header="A property is not a variable"
A property assigned to a function like `sayHi.counter = 0` does *not* define a local variable `counter` inside it. In other words, a property `counter` and a variable `let counter` are two unrelated things. A property assigned to a function like `sayHi.counter = 0` does *not* define a local variable `counter` inside it. In other words, a property `counter` and a variable `let counter` are two unrelated things.
We can treat a function as an object, store properties in it, but that has no effect on its execution. Variables never use function properties and vice versa. These are just parallel words. We can treat a function as an object, store properties in it, but that has no effect on its execution. Variables never use function properties and vice versa. These are just parallel worlds.
``` ```
Function properties can replace closures sometimes. For instance, we can rewrite the counter function example from the chapter <info:closure> to use a function property: Function properties can replace closures sometimes. For instance, we can rewrite the counter function example from the chapter <info:closure> to use a function property: