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... 阅读全文
posted @ 2017-05-30 18:08 ax=null 阅读(336) 评论(0) 推荐(0)
摘要: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 , ... 阅读全文
posted @ 2017-05-30 18:06 ax=null 阅读(355) 评论(0) 推荐(0)
摘要:var o = { c: 'hello'}console.log(o['a', 'b', 'c']); // hello ==> o['c'] var a = (1, 2, 3); console.log(a); // 3 阅读全文
posted @ 2017-05-19 21:10 ax=null 阅读(143) 评论(0) 推荐(0)
摘要:某数二进制右移一位得到他的一办: 10>>>1 => 5 阅读全文
posted @ 2017-05-19 15:11 ax=null 阅读(76) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2017-05-16 00:09 ax=null 阅读(214) 评论(0) 推荐(0)
摘要:process.stdin.pipe(process.stdout); 阅读全文
posted @ 2017-05-15 21:33 ax=null 阅读(102) 评论(0) 推荐(0)
摘要:async function sleep(timeout) { return new Promise((resolve, reject) => { setTimeout(function() { resolve('timeout'); }, timeout); });} (async functio 阅读全文
posted @ 2017-05-15 15:39 ax=null 阅读(121) 评论(0) 推荐(0)
摘要:var obj = { valueOf: function() { return 3; }, toString: function() { return 2; }}; const sym = Symbol(obj);console.log(sym); // 'Symbol(2)' call toSt 阅读全文
posted @ 2017-05-15 11:36 ax=null 阅读(204) 评论(0) 推荐(0)
摘要: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] 阅读全文
posted @ 2017-05-15 11:25 ax=null 阅读(116) 评论(0) 推荐(0)
摘要:Array.prototype.clone = function() { return this.slice();} var arr= [1,2, 3];var arr2 = arr.clone();console.log(arr2); // [1, 2, 3] 阅读全文
posted @ 2017-05-11 00:51 ax=null 阅读(120) 评论(0) 推荐(0)
摘要:var arr = [1, 2, 3,[false], ['hello']];var arr2 = [].concat.apply([], arr);console.log(arr2); // [ 1, 2, 3, false, 'hello' ] 阅读全文
posted @ 2017-05-07 16:21 ax=null 阅读(186) 评论(0) 推荐(0)
摘要:var arr = [1, 2]; arr[arr.length] = 3; console.log(arr); // 速度比 push 快 阅读全文
posted @ 2017-05-03 22:53 ax=null 阅读(190) 评论(0) 推荐(0)
摘要:function Employee(name) { this.name = name; this.say = function() { log.add("I am employee " + name); } } function EmployeeFactory() { this.create = function(name) { return new Employee(); ... 阅读全文
posted @ 2017-05-03 21:37 ax=null 阅读(156) 评论(0) 推荐(0)
摘要: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... 阅读全文
posted @ 2017-05-03 21:19 ax=null 阅读(682) 评论(0) 推荐(0)
摘要: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 ... 阅读全文
posted @ 2017-05-03 21:18 ax=null 阅读(136) 评论(0) 推荐(0)
摘要: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... 阅读全文
posted @ 2017-05-03 21:16 ax=null 阅读(143) 评论(0) 推荐(0)
摘要:{ var a = 2 } console.log(a); // 2 { let b = 3; } console.log(b); // err b is not defined 阅读全文
posted @ 2017-05-01 13:55 ax=null 阅读(108) 评论(0) 推荐(0)