const quiz1 = ({ a, b = 2 }) => b;
const quiz2 = ({ a, b = 2 } = {}) => b;
const quiz3 = ({ a, b = 2 } = { b: 3 }) => b;
const quiz4 = ({ a, b } = { b: 3 }) => b;
const quiz5 = ({ a, b }) => b;quiz1 |
quiz2 |
quiz3 |
quiz4 |
quiz5 |
|
|---|---|---|---|---|---|
quiz() |
? | ? | ? | ? | ? |
quiz({}) |
? | ? | ? | ? | ? |
quiz({ a: 1 }) |
? | ? | ? | ? | ? |
quiz(null) |
? | ? | ? | ? | ? |
[copy and paste this below]
| | `quiz1` | `quiz2` | `quiz3` | `quiz4` | `quiz5` | | - | - | - | - | - | - | | `quiz()` | ? | ? | ? | ? | ? | | `quiz({})` | ? | ? | ? | ? | ? | | `quiz({ a: 1 })` | ? | ? | ? | ? | ? | | `quiz(null)` | ? | ? | ? | ? | ? |
And for those in a hurry:
Answers
Are you sure you wanna see the answers?
For real, it's no fun if you don't try for yourself first
I see I see, you're a 10x JavaScript ninja, and you would get them all right anyway, gotcha..
HERE YOU GO.
Exactly one of these cells is wrong. RIP.
quiz1quiz2quiz3quiz4quiz5quiz()TypeErrorquiz({})undefinedundefinedquiz({ a: 1 })undefinedundefinedquiz(null)TypeErrorTypeErrorTypeErrorTypeErrorTypeError