react笔记之箭头函数2

<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>箭头函数</title>
<script>
/*
* 1.箭头函数中没有arguments
* 2.箭头函数中没有自己的this
* - 它的this总是外层作用域的this
* 3.箭头函数中的this无法通过call()、apply()、bind()修改
* 4.箭头函数无法作为构造函数使用
*
* */
function fn(a, b, ...args){
// arguments用来保存函数的实参
// console.log(arguments.length);
console.log(args);
}
const fn2 = (...args)=>{
console.log(args);
};
const fn3 = () => {
console.log(this);
};
const obj = {
hello:()=>{
console.log(this);
}
};
const obj2 = {
hello:function (){
const test = () => {
console.log('-->',this);
};
test();
}
};
obj2.hello();
// new fn3();
</script>
</head>
<body>
</body>
</html>

posted @   前端导师歌谣  阅读(27)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
点击右上角即可分享
微信分享提示