当前位置:网站首页>手写代码 bind
手写代码 bind
2022-06-10 19:16:00 【小李科技】
function f1(a,b,c) {
console.log('this', this);
console.log(a,b,c);
return 'this is fn1'
}
const fn = f1.bind({
x:100}, 100,200,400)
Function.prototype.mybind = function () {
// 类数组不能直接使用数组方法, Array.prototype.slice.call 转换为数组形式
// 将类数组===> 转换为数组
const args = Array.prototype.slice.call(arguments)
// args = [1,2,3]
// 获取this
const t = args.shift() // 去除第一个参数, 会改变原数组==>1, 剩余 [2,3 ]
const self = this
return function () {
return self.apply(t, args)
}
}
边栏推荐
- 补水仪108K加湿器开发方案_单片机_NY8A051F_单片机开发设计开发
- 站在今天这样一个时间节点上,或许对产业互联网有一个更加明晰的认识
- Spark ShuffleManager
- 仅需三步学会使用低代码ThingJS与森数据DIX数据对接
- 2022.05.26 (lc_1143_longest common subsequence)
- I drew several exquisite charts with plotly, which turned out to be beautiful!!
- Batch detection of specified ports of different URLs (py script)
- Tencent cloud database tdsql- a big guy talks about the past, present and future of basic software
- 今年高考期间各考点秩序井然,未发生影响安全的敏感案事件
- 618 great promotion is coming, mining bad reviews with AI and realizing emotional analysis of 100 million comments with zero code
猜你喜欢

618 great promotion is coming, mining bad reviews with AI and realizing emotional analysis of 100 million comments with zero code

Flutter series: UI layout introduction

VR全景作品中各式各样的嵌入功能是如何做到的?
![[6.4-6.10] wonderful review of Blog](/img/66/0cfc97bf4bc0c2b6e66c0419690ce5.png)
[6.4-6.10] wonderful review of Blog

2022.05.26 (lc_1143_longest common subsequence)

Spark ShuffleManager

2022.05.25 (lc_718_longest repeating subarray)

SBC芯片35584数据手册预调节器翻译

In the all digital era, how can enterprise it complete transformation?

MySQL数据库基础
随机推荐
Basic instructions for ads and AXD
2022.05.29 (lc_6079_price reduction)
Esp8266 system environment setup
2022.05.29 (lc_6078_rearranges characters to form target string)
Summary of "performance test" of special test
First batch! Sinomenine has passed CWPP capability assessment and inspection of Xintong Institute
Logback exclude specified package / class / method log output
Bit operation topic
Rmarkdown easily input mathematical formula
企业级存储发展趋势谈:开源存储的冷思考
When the college entrance examination is opened, VR panorama can see the test site in this way
Source code analysis of Tencent libco collaboration open source library (III) -- Exploring collaboration switching process assembly register saving and efficient collaboration environment
Does Seata still not support sqlserver?
2022 年 DevOps 路线图|Medium
Mongodb 唯一索引
Rmarkdown 轻松录入数学公式
补水仪108K加湿器开发方案_单片机_NY8A051F_单片机开发设计开发
用 Plotly 绘制了几张精湛的图表,美翻了!!
大厂测试员年薪30万到月薪8K,吐槽工资太低,反被网友群嘲?
历时2年442位作者132个机构!Google发布语言模型评价新基准BIG-bench,204个任务全面评价语言模型能力,附论文