This file contains 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
-----BEGIN PGP PUBLIC KEY BLOCK----- | |
mQGNBF4et1wBDADKQeFwnhBB7OoVW8DZuEvxxjhilx+OOksTgnELPxUsbK1RMKgo | |
251jlHDyNR1EVkgB2q0c/6kDMALpaGhLjPdG3Hycba/z/sJWHGLwq1gsbPhSKJBF | |
NUvZXvGcHNOIMV70rf40KoAQV8qdfSWdAkVstp+OjHjNjl/02k91hZ/w1o0Mag7/ | |
G1So0gK2ubYqv2zh6kJJ5LlTxaYF9gEZfLaVecvB87SKNXWpjsoPynZSeADLywsr | |
1aQCKocfglwKqLudXeGD+j5bqXYJL8sfFnVmorAMcliwH/g1Vk+EVS/9tDKmxTL5 | |
0FFRRPqskqoDq/uY1E8kr7W0n3b2m9OPPwEzZo62E2LYznmTbVaelYrLUI41rfuh | |
njCjLZNeas1SAfDnEW8ibl+BWW81c9tj5dITQFcSlwMftoA2OvE3oVWmCOTJPEBI | |
RoGsv4c2vTfcaJkOzJiU3SdQI2fxQTXcegbzBOWD1+ZoNJRAaSlOL8AEb6wPdEIu |
This file contains 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 arr = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']; | |
function shuffle(arr) { | |
let cac; | |
let len = arr.length - 1; | |
let ran; | |
for (let i = 0; i < len; i++) { | |
// 保存当前位 | |
cac = arr[i]; | |
// 剩下位的随机抽取 | |
ran = Math.floor(Math.random() * (len - i + 1) + i); |
This file contains 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
// new | |
function type(target) { | |
let temp = { | |
"[object String]": 'ObjectString', | |
"[object Number]": 'ObejctNumber', | |
"[object Array]": 'Array', | |
"[object RegExp]": 'RegExp', | |
"[object Date]": 'Date' | |
} | |
if (target === null) { |
This file contains 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
Array.prototype.unique = function () { | |
let x, | |
y; | |
let uni = {}; | |
for (x of this) { | |
uni[x] = 'xfy'; | |
} | |
let arr = Object.keys(uni); | |
return arr; | |
} |
This file contains 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 xfy = (() => { | |
let name = 'xfy'; | |
let age = 18; | |
let obj = {}; | |
Object.defineProperty(obj, 'test', { | |
get: function () { | |
return name + ' : ' + age; | |
}, | |
set: function (value) { | |
name = value; |
This file contains 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 fibonacci(num) { | |
let count = 0; | |
let result = [1, 1]; | |
if (num <= 1) { | |
return result; | |
} | |
let n = num - 2; | |
for (let i = 0; i < n; i++) { | |
result.push(result[count] + result[count + 1]); | |
count++; |
This file contains 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 obj = { | |
a: "xfy", | |
b: { | |
c: "test", | |
}, | |
d: 123, | |
e: [1, 2, 3, 4, 5], | |
f: { | |
g: 'array', | |
h: [1, 2, 3, 4, 5, 6, { |
This file contains 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
// "typescript": "~4.1.5" | |
type Debounce = { | |
<T extends unknown[]>(fn: (...arg: T) => void | unknown, ms: number): ( | |
this: unknown, | |
...arg: T | |
) => void | unknown; | |
}; | |
/** | |
* debounce function wrapper |
This file contains 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* fibonacciSquence() { | |
let x = 0, | |
y = 1; | |
for (;;) { | |
yield y; | |
[x, y] = [y, x + y]; | |
} | |
} | |
const fibonacci = (n: number) => { |
This file contains 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 arr = [ | |
{ name: 'zs', age: 15, happy: ['唱歌', '玩游戏'] }, | |
{ name: 'ls', age: 15, happy: ['玩游戏'] }, | |
{ name: 'zs', age: 15, happy: ['学习', '划水'] }, | |
]; | |
function test(arr) { | |
let _obj = {}; | |
let _arr = []; | |
if (!arr.length) return; |
OlderNewer