波仔糕

Results 27 comments of 波仔糕

``` js Function.prototype.customCall = function (context) { context.fn = this; let params = Array.from(arguments) let result = context.fn(...params.slice(1)) delete context.fn; return result; } Function.prototype.customApplay = function (context) { context.fn =...

所谓虚拟DOM实际上就是一个js对象,通过操作更新js对象实现批量更新的效率比直接操作DOM效率更高,至于更快的方式的话只有去提高diff算法的执行效率才能达成这个目标。

if (window.document.body.clientWidth === window.screen.width){ alert('全屏显示'+window.screenLeft) }

setTimeout只执行一次,而setInterval可以一直执行,setTimeout可以模拟setInterval操作: ```js function timeFun() { setTimeout(() => { timeFun() console.log('setTimeout'); }, 1000) } setTimeout(() => { timeFun() }, 1000) ``` 在模拟的时候可以在内部根据逻辑判断终止循环执行,而setInterval必须通过手动通过clearInterval才能终止循环执行。

JSON.stringify(object1) === JSON.stringify(object2)

new操作符做了四件事:初始化一个对象、将对象的原型指向构造函数的prototype、将构造函数的this指向这个对象、返回这个对象。 ``` js function objectFactory() { let object = new Object(), Constractor = [].shift.call(arguments); object.__proto__ = Constractor.prototype; Constractor.apply(object, arguments) return object; } ```

Object.keys({name:'test'}).length !== 0

My computer has an M1 chip,I tried everything. The most important changes are as follows: nvm unalias default nvm alias default node