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
| // 123456789 -> 123,456,789 | |
| n.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); |
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
| // #1 - for | |
| let images = [ 'test.jpg', 'dummy.gif' ]; | |
| for (let i = 0; i < allImgs.length; i++) {} // long | |
| for (let i of allImgs) { } // short | |
| // #2 - decimal base | |
| 1000000 === 1e6 | |
| // #3 - default parameters | |
| volume = (l, w = 3, h = 4 ) => (l * w * 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
| // helper functions | |
| const compose = (...fns) => x => fns.reduceRight((res, fn) => fn(res), x); | |
| const tap = f => x => { f(x); return x; }; | |
| const trace = label => tap(console.log.bind(console, label + ':')); | |
| // container helpers | |
| const isFunction = fn => fn && Object.prototype.toString.call(fn) === '[object Function]'; | |
| const isAsync = fn => fn && Object.prototype.toString.call(fn) === '[object AsyncFunction]'; |
OlderNewer