function coloring(){ let r=Math.random() * 255; let g=Math.random() * 255; let b=Math.random() * 255; document.body.style.backgroundColor="rgb("+r+","+g+","+b+")"; } window.addEventListener("resize", throttle(coloring,2000)) function throttle(func,delay){ let timer; return function() { let context=this; let args=arguments; if(timer){ return; } timer=setTimeout(function() {func.apply(context,args)}, delay); }
}
function m(){console.log(this)};//window var cat={name:"tom"}; cat.m=m; cat.m();//cat //window.m();//window //window.m.call(cat);//cat //window.m.apply(cat);//cat
}
function m(){console.log(this)};//window var cat={name:"tom"}; cat.m=m; cat.m();//cat //window.m();//window //window.m.call(cat);//cat //window.m.apply(cat);//cat