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
| console.log(Array.from(someObject)) // [1, "Yolodog", "a"] | |
| // con spread operator: | |
| console.log([...someObject]) // [1, "Yolodog", "a"] | |
| console.log(...someObject) // 1 "Yolodog" "a" |
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 someObject = { | |
| a: 1, | |
| perrito: 'Yolodog', | |
| aChar: 'a', | |
| } | |
| someObject[Symbol.iterator] = function() { | |
| let currentKey = 0; | |
| const keys = Object.keys(this); | |
| const { length } = keys; |
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
| function makeIterator(array) { | |
| let nextIndex = 0; | |
| return { | |
| next: function() { | |
| return nextIndex < array.length ? | |
| {value: array[nextIndex++], done: false} : | |
| {done: true}; | |
| } | |
| }; | |
| } |
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 someArray = [2, 4, 8]; | |
| for (let n of someArray) { console.log(n); } | |
| // 2 | |
| // 4 | |
| // 8 |
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
| for (let char of 'yo!') { console.log(char); } | |
| // y | |
| // o | |
| // ! |
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 someArray = [2, 4, 8]; | |
| let someArraySquared = []; | |
| for (let n of someArray) { | |
| someArraySquared.push(n * n); | |
| } | |
| console.log(someArray, someArraySquared); |
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 someArray = [2, 4, 8]; | |
| let someArraySquared = someArray.map(x => x * x); | |
| console.log(someArray, someArraySquared); // [2, 4, 8], [4, 16, 64] |
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 someArray = [2, 4, 8]; | |
| let someArraySquared = []; | |
| for (let i = 0; i < someArray.length; i += 1) { | |
| someArraySquared.push(someArray[i] * someArray[i]); | |
| } | |
| console.log(someArray, someArraySquared); // [2, 4, 8], [4, 16, 64] |
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
| /* VT100 terminal reset (<ESC>c) */ | |
| console.log('\033c'); | |
| /* numbers comparations */ | |
| > '2' == 2 | |
| true | |
| > '2' === 2 |
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
| var html = (function () {/* | |
| <!DOCTYPE html> | |
| <html> | |
| <body> | |
| <h1>Hello, world!</h1> | |
| </body> | |
| </html> | |
| */}).toString().match(/[^]*\/\*([^]*)\*\/\}$/)[1]; |