11# JS tricks
22
3- ` Object.assign ` is useful on arrays.
3+ ## ` Object.assign ` is also useful on arrays
44
55```
66const initialScores = [0, 0, 0];
@@ -11,7 +11,7 @@ const scores = [5, 2, 7];
1111Object.assign(scores, initialScores);
1212```
1313
14- ` {} ` can be used to create local scopes anywhere
14+ ## ` {} ` can be used to create local scopes anywhere
1515
1616```
1717const minMax = function (numbers) {
@@ -33,7 +33,7 @@ const minMax = function (numbers) {
3333```
3434
3535
36- Array destructuring syntax can be used to swap variables;
36+ ## Array destructuring syntax can be used to swap variables
3737
3838```
3939let a = 5;
@@ -42,14 +42,14 @@ let b = 2;
4242```
4343
4444
45- Remove duplicates from an array
45+ ## ` new Set ` to remove duplicates from an array
4646
4747```
4848let a = [5, 4, 4, 4, 3];
4949a = [...(new Set(a))];
5050```
5151
52- Object.seal and Object.freeze to ensure that an external object does not exceed an Interface
52+ ## ` Object.seal ` to ensure that a passed object does not exceed an interface
5353
5454```
5555const requestInterface = {
@@ -78,7 +78,7 @@ handleRequest({
7878});
7979```
8080
81- default assignement syntax to log for required parameters
81+ ## Default assignement syntax to log for required parameters
8282
8383```
8484const required = function () {
@@ -94,7 +94,7 @@ const slowVector3 = function (vector3 = required()) {
9494slowVector3() --> Error: required parameter missing
9595```
9696
97- It works really well with destructuring too
97+ ## Required parameters + destructuring
9898
9999
100100```
0 commit comments