摘要: ###别人写的call的实现(xiuyan) Function.prototype.myCall = function(context, ...args){ // 把函数挂到目标对象上 context.func = this; // 执行函数 context.func(...args); // 删除 阅读全文
posted @ 2021-07-06 18:24 小白yang 阅读(49) 评论(0) 推荐(0)
摘要: this指向其调用者 注意this声明位置与调用位置 // 声明位置 var me={ name:'lizzy', hello: function(){ console.log(`Hello, my name is ${this.name}`); } } var you = { name:'zzjw 阅读全文
posted @ 2021-07-06 10:59 小白yang 阅读(31) 评论(0) 推荐(0)
摘要: 题目 const a = {}; const b = {key:'b'}; const c = {key:'c'}; a[b] = 123; a[c] = 456 console.log(a[b]); 答案是456,因为对象作为键值会自动转化为字符串,a[b]相当于a['Object Object' 阅读全文
posted @ 2021-07-06 10:29 小白yang 阅读(277) 评论(0) 推荐(0)
摘要: // async和await function wait (data) { return new Promise(resolve => { setTimeout(function () { resolve(data); }, 1000) }) } async function main (param 阅读全文
posted @ 2021-07-06 10:03 小白yang 阅读(44) 评论(0) 推荐(0)