Collection of front-end interview skills Part 6: High-frequency test points (event mechanism & cross-domain & storage mechanism & browser cache, etc.)

This is a record 前端面试的话术集锦第六篇博文——高频考点(事件机制 & 跨域 & 存储机制 & 浏览器缓存等)and I will keep updating this blog post. ❗❗❗

1. Hand-written call, apply and bind functions


First, consider how to implement these functions from the following points:

  1. If the first parameter is not passed in, the context defaults towindow

  2. The pointer is changed thisso that the new object can execute the function and accept parameters.

  • Implementation call:
  1. The first contextis an optional parameter. If not passed, the default context iswindow

  2. Next, contextcreate a fnproperty and set the value to the function that needs to be called.

  3. Because callmultiple parameters can be passed in as parameters of the calling function, the parameters need to be stripped out.

  4. Then call the function and delete the function on the object

Function.prototype.myCall = 

Guess you like

Origin blog.csdn.net/lvoelife/article/details/132655138