A Pen by JunesiPhone on CodePen.
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
| #!/bin/sh | |
| # Script to compile nginx on ubuntu with lua support. | |
| NGX_VERSION='1.6.2' | |
| LUAJIT_VERSION='2.0.3' | |
| LUAJIT_MAJOR_VERSION='2.0' | |
| NGX_DEVEL_KIT_VERSION='0.2.19' | |
| LUA_NGINX_MODULE_VERSION='0.9.15' | |
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 sortCharactersInString = str => | |
| str.split('').sort((a, b) => a.localeCompare(b)).join(''); | |
| sortCharactersInString('cabbage') -> 'aabbceg' |
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 countOccurrences = (arr, value) => arr.reduce((a, v) => v === value ? a + 1 : a + 0, 0); | |
| countOccurrences([1,1,2,1,2,3], 1) -> 3 | |
| //使用Array.reduce()在每次遇到数组中的特定值时递增计数器 | |
| var arr = 'abcdaabc'; | |
| var info = arr.split('').reduce((p, k) => (p[k]++ || (p[k] = 1), p), {}); | |
| console.log(info); | |
| //{ a: 3, b: 2, c: 2, d: 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
| const getType = v => === undefined ? 'undefined' : v === null ? 'null' : v.constructor.name.toLowerCase(); | |
| getType(new Set([1,2,3])) // "set" |
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
| String.prototype.trim = function () { | |
| return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); | |
| }; | |
| // or | |
| // \/^s*|s*$\/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
| const sortCharactersInString = str => | |
| str.split('').sort((a, b) => a.localeCompare(b)).join(''); | |
| // sortCharactersInString('cabbage') -> 'aabbceg' |
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 arr = 'abcdaabc'; | |
| var info = arr | |
| .split('') | |
| .reduce((p, k) => (p[k]++ || (p[k] = 1), p), {}); | |
| console.log(info); //{ a: 3, b: 2, c: 2, d: 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
| if( Object.prototype.toString.call( someObject ) === '[object Object]' ) { | |
| // do your iteration | |
| } |
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
| /^s*|s*$/g |
OlderNewer