摘要: 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 阅读(155) 评论(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 阅读(681) 评论(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 阅读(135) 评论(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 阅读(142) 评论(0) 推荐(0)