mirror of
https://github.com/airbnb/javascript.git
synced 2026-01-14 04:48:12 -05:00
add semicolons
This commit is contained in:
committed by
Josh Perez
parent
e5006931f1
commit
d0028724ea
18
README.md
18
README.md
@@ -550,21 +550,21 @@
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
- Don't put side effect into default parameter
|
||||
|
||||
> it introduces confusion and subtlety. Arguments in function call are evaluated at call site, but default parameters are not evaluated at define site.
|
||||
|
||||
> it introduces confusion and subtlety. Arguments in function call are evaluated at call site, but default parameters are not evaluated at define site.
|
||||
|
||||
```javascript
|
||||
var b = 1
|
||||
var b = 1;
|
||||
// bad
|
||||
function count(a = b++) {
|
||||
console.log(a)
|
||||
console.log(a);
|
||||
}
|
||||
count() // 1
|
||||
count() // 2
|
||||
count(3) // 3
|
||||
count() // 3
|
||||
count(); // 1
|
||||
count(); // 2
|
||||
count(3); // 3
|
||||
count(); // 3
|
||||
```
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user