05 2017 档案
摘要:function findMaxDepulicateChar(str) { var obj = {}; for (let i = 0, len = str.length; i max) { max = obj[key]; maxChar = key; } } return ('maxChar:' + maxChar + ' sum:' + m...
阅读全文
摘要:function bubbleSort(arr) { if (arr.length arr[j + 1]) { var temp = arr[j + 1]; arr[j + 1] = arr[j]; arr[j] = temp; } } } return arr; } var arr = [1,34 ,3 , ...
阅读全文
摘要:var o = { c: 'hello'}console.log(o['a', 'b', 'c']); // hello ==> o['c'] var a = (1, 2, 3); console.log(a); // 3
阅读全文
摘要:alt-d/del: 删除后/前单词 ctrl-d/del:删除后/前字符 ctrl-x-h:全选 ctrl-t:字符交换 alt-t:单词交换 ctrl-x ctrl-t 交换两行的位置 alt-m:到当前行第一个字符 alt-u/l:把一个单词变成大写/小写 alt-c:字符大写 alt/ctr
阅读全文
摘要:process.stdin.pipe(process.stdout);
阅读全文
摘要:async function sleep(timeout) { return new Promise((resolve, reject) => { setTimeout(function() { resolve('timeout'); }, timeout); });} (async functio
阅读全文
摘要:var obj = { valueOf: function() { return 3; }, toString: function() { return 2; }}; const sym = Symbol(obj);console.log(sym); // 'Symbol(2)' call toSt
阅读全文
摘要:function dedupe(arr) { return Array.from(new Set(arr));} var arr = [2,2,3,4,5,4];console.log(dedupe(arr)); // [2, 3, 4, 5]
阅读全文
摘要:Array.prototype.clone = function() { return this.slice();} var arr= [1,2, 3];var arr2 = arr.clone();console.log(arr2); // [1, 2, 3]
阅读全文
摘要:var arr = [1, 2, 3,[false], ['hello']];var arr2 = [].concat.apply([], arr);console.log(arr2); // [ 1, 2, 3, false, 'hello' ]
阅读全文
摘要:var arr = [1, 2]; arr[arr.length] = 3; console.log(arr); // 速度比 push 快
阅读全文
摘要:function Employee(name) { this.name = name; this.say = function() { log.add("I am employee " + name); } } function EmployeeFactory() { this.create = function(name) { return new Employee(); ...
阅读全文
摘要:var arr = ['a', 'b', 'c']; // 1 for (var index = 0; index < arr.length; index++) { console.log(arr[index]); } // 2 ES5 arr.forEach(function (value) { console.log(value); }); // 3 for-in work the...
阅读全文
摘要:var s1 = `string text`; console.log(s1); console.log(typeof(s1)); var s2 =`text line1 text line2`; console.log(s2); // true console.log('\`' === '`'); var a = 1, b = 2; console.log(`sum ...
阅读全文
摘要:function* fib() { let previous = 0; let current = 1; while (true) { yield current; const next = current + previous; previous = current; current = next; } } /* output: 1 1 2 3...
阅读全文
摘要:{ var a = 2 } console.log(a); // 2 { let b = 3; } console.log(b); // err b is not defined
阅读全文

浙公网安备 33010602011771号