Skip to content

Commit 83d72c6

Browse files
authored
Update JavaScript.md
1 parent 3de346b commit 83d72c6

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

JavaScript.md

+14
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,17 @@ doStuff(...args);
2929

3030
With the spread operator we can avoid apply all together and simply call the function with the spread operator. [Read more...](https://davidwalsh.name/spread-operator).
3131
Note: although there it looks simpler, I think this is less readable at the moment since more developers are familiar with apply.
32+
33+
34+
* What is [destructuring assignment](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment)?
35+
* Explain why the below stand-alone syntax is not valid?
36+
37+
```js
38+
{a, b} = {a: 1, b: 2}
39+
```
40+
41+
{a, b} on the left-hand side is considered a block and not an object literal.
42+
43+
However, ({a, b} = {a: 1, b: 2}) is valid, as is const {a, b} = {a: 1, b: 2}
44+
45+
Your ( ... ) expression needs to be preceded by a semicolon or it may be used to execute a function on the previous line.

0 commit comments

Comments
 (0)