kexiaofu

Results 5 comments of kexiaofu

我在想,问题的表达式能不能改写成这样 ```javascript var a = { n : 1}; var b = a; a.x; a = { n: 2 }; b.x = a; console.log(a.x); console.log(b.x); ``` 因为 `.` 优先级比 `=`...

先看ES5的继承(原型链继承) ```javascript function a() { this.name = 'a'; } a.prototype.getName = function getName() { return this.name } function b() {} b.prototype = new a(); console.log(b.prototype.__proto__ === a.prototype); // true console.log(b.__proto__...

我觉得插入排序也ok,不合并再排序。或许只针对这个题目有效。而且 `indexof` 的性能的确可能会比自己做比较运算的慢,所以仅供参考。 ```javascript let a = ['A1', 'A2', 'B1', 'B2', 'C1', 'C2', 'D1', 'D2'], b = ['A', 'B', 'C', 'D']; let d = []; a.map(item => { if (item.indexOf(b[0])...

先来抛砖,希望可以引玉 ```javascript function add() { const args = Array.prototype.slice.apply(arguments); const self = this; this.nums = [...args]; function _add() { const _args = Array.prototype.slice.apply(arguments); this.nums.push(..._args); return _add; } _add.value = function()...

其实我还有一个思路: - 收集参数部分相同; - 在 run 的时候,判断 task.then 是否是可执行的方法,请看代码 ```javascript function isType(target, type) { return (Object.prototype.toString.call(target) || '').indexOf(type) > -1; } function log(msg) { return console.log(msg); } function createFlow(arr) {...