前端入门知识点笔记本之js重定位函数
2024-10-21 09:21:36
1.
call()、bind()、apply()的用法,改变this的指向,区别在于
f.call(obj, arg1, arg2...),
f.bind(obj, arg1, arg2,...)(),
f.apply(obj, [arg1, arg2, .])
Example:封装函数 f,使 f 的 this 指向指定的对象
(1)apply()
function bindThis(f, oTarget) {
return function() {
return f.apply(oTarget, arguments)
}
}
(2)bind()
function bindThis(f, oTarget) {
return f.bind(oTarget)
}
(3)call()
function bindThis(f, oTarget) {
return function() {
return f.call(oTarget, ...arguments)
}
}
最新文章
- Linq 单表城市级联
- 乌邦图ubuntu配置iptables的NAT上网
- 清除Windows的DNS缓存
- 68.Android之透明状态栏
- Nodejs开源项目推荐
- 关于DOM树的常见增删操作
- Eclipse中设置JDK内存方式
- TCP/UDP详解
- 排队(BZOJ1731:[Usaco2005 dec]Layout 排队布局)
- 安装使用GYP,并编译libpomelo2
- session 与 cookie (一)
- python selenium 爬取淘宝
- python open函数的坑
- 常用的.NET开源项目(转)
- Com类型
- Mockito学习1
- 前端基础-html 介绍和head标签 ( 1 )
- HTML DOM item() 方法
- UEditor插入视频,Object Iframe等标签被过滤问题处理
- NSOperation的使用细节 [1]
热门文章
- 手机、ESP32单片机、MQTT服务器连接实验
- uniapp(1)
- (1028) 权限,chmod、chgrp、chown详解
- Delphi 新语法:匿名函数
- MCU构成及其运行原理
- 提取可执行文件中的调试信息 objcopy --only-keep-debug app app.debug
- 虚拟机中debian11修改控制台(console)分辨率|linux控制台分辨率|linux console resolution
- DSL语言思想的应用
- pyton3 字典排序
- SpringBoot(十五)单个以及多个跨域的配置方法