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.
quiz1
quiz2
quiz3
quiz4
quiz5
quiz()
TypeError
quiz({})
undefined
undefined
quiz({ a: 1 })
undefined
undefined
quiz(null)
TypeError
TypeError
TypeError
TypeError
TypeError