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 dog = () => { | |
| const sound = 'woof'; | |
| return { | |
| talk: () => console.log(sound) | |
| }; | |
| }; | |
| const bark = dog(); | |
| bark.talk(); |
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 barker = (state) => | |
| // const barker = state => ({ | |
| // bark: () => console.log(`Woof, I am ${state.name}`) | |
| // }); | |
| const barker = state => ({ | |
| bark: () => console.log(`Woof, I am an ${state.name}`) | |
| }); |
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
| greet(); | |
| a(); | |
| const a = function () { | |
| console.log('h1'); | |
| }; | |
| function greet() { | |
| console.log('h2'); | |
| } |
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
| // greet(); | |
| // a(); | |
| const a = function () { | |
| console.log('h1'); | |
| }; | |
| function greet() { | |
| console.log('h2'); | |
| } |
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 a = x => console.log(x); | |
| a(() => console.log('h1')); | |
| // create a function on the fly | |
| console.log(() => console.log('this is stupid')); | |
| const b = x => x(); | |
| b(() => console.log('this is even stupier')); |
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
| getComputedStyle(document.getElementById('blue')).getPropertyValue('width') |
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
| // export default l => () => console.log(12) | |
| // export default l => (console.log('12')) | |
| // export default l => ({ ll: () => 12}) | |
| // const l = () => 2 | |
| // // console.log(l()) | |
| // export { l } |
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 higher (d) ({ | |
| add3: () => (d + 3) | |
| }) | |
| const higher = (d) => ({ | |
| add3: () => d + 3 | |
| }) | |
| class higher { | |
| constructor (d) { |
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 counter = () => ({ | |
| count: s => { | |
| return 'haha' + s | |
| } | |
| }) | |
| class counter { | |
| count(s) { | |
| return 'haha' + s | |
| } |
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 str = 'sajldfj jksdfajl akljf kdaj kjfsak jk' | |
| let regex = /\w+/g | |
| console.log(str.match(regex)) | |
| console.log(str.match(NaN)) | |
| console.log(str.match(/jjslkdjfalkj/)) |