文章目录 一、call、apply、bind 1.1 call方法 1.2 apply方法 1.3 bind方法 1.4 call、apply、bind区别 二、手写bind 2.1 普通函数调用情况 2.2 构造函数调用情况 2.3 bind手写实现 在实现bind方法之前,我们知道call、apply和bind是三个重要的函数方法,它们都与函数调用和this关键字有关。本文将讲解它们之间的使用和区别以及bind的实现思路。 一、call、apply、bind 1.1 call方法 call方法是Function对象原型上的一个方法,它允许你在调用函数的同时显式指定函数的this值,并且可以传递多个参数。 function fn(val) { console.log(this, val); } const