Skip to content

Commit 9ad04f3

Browse files
authored
Merge pull request nzakas#319 from kwasniew/defaultparams
Forcing default param to be undefined
2 parents 6995201 + b2180c1 commit 9ad04f3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

manuscript/03-Functions.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,11 @@ function add(first = second, second) {
259259
return first + second;
260260
}
261261

262-
console.log(add(1, 1)); // 2
263-
console.log(add(1)); // throws error
262+
console.log(add(1, 1)); // 2
263+
console.log(add(undefined, 1)); // throws error
264264
```
265265

266-
The call to `add(1)` throws an error because `second` is defined after `first` and is therefore unavailable as a default value. To understand why that happens, it's important to revisit temporal dead zones.
266+
The call to `add(undefined, 1)` throws an error because `second` is defined after `first` and is therefore unavailable as a default value. To understand why that happens, it's important to revisit temporal dead zones.
267267

268268
### Default Parameter Value Temporal Dead Zone
269269

0 commit comments

Comments
 (0)