This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const args = [0, 1, 2]; | |
| function foo (x, y, z) { | |
| // do stuff... | |
| // we are not using this keyword in foo() | |
| } | |
| // Call function | |
| foo.apply(null, args); | |
| // Using ... instead |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const arrA = [1, 2, 3]; | |
| const arrB = [4, 5, 6]; | |
| arrA.push(...arrB); // [1, 2, 3, 4, 5, 6] | |
| let arrC = [1, 2, 3]; | |
| let arrD = [4, 5, 6]; | |
| arrC = [...arrC, ...arrD]; // [1, 2, 3, 4, 5, 6] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let lists = ['pizza', 'poo']; | |
| let results = ['mark', ...lists, 'too']; | |
| // result = ["mark", "pizza", "poo", "too"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let arrA = [1, 2, 3]; | |
| let copyA = [...arrA]; // [1, 2, 3] immutable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let name = 'Prayuth'; | |
| let spreadName = [...name]; // "P", "r", "a", "y", "u", "t", "h"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let number = [9, 8, 7, 1]; | |
| console.log(Math.min(number)); // NaN | |
| console.log(Math.min(...number)); // 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 }; | |
| console.log(x); // 1 | |
| console.log(y); // 2 | |
| console.log(z); // { a: 3, b: 4 } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const profile = { | |
| name: 'Teerapong Singthong' | |
| }; | |
| const position = { | |
| job: 'Business Maker' | |
| }; | |
| const summary = {...profile, ...position}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const profile = { | |
| name: 'Teerapong Singthong' | |
| }; | |
| const position = { | |
| job: 'Business Maker' | |
| }; | |
| const summary = {...profile, job: 'Developer'}; | |
| /* |

