<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script>
//箭头函数没有自己的this
//用call和apply不能改变他的this,他的this从属于所处上下文
//回调函数中的this一般指的都是window
//回调函数就是把一个函数作为实参传给另一个函数,
// setTimeout(function() {
// console.log(this)
// }, 10000);
//
// let l = [{a:1},{a:2},{a:0}]
// l.sort(function(x,y){
// console.log(this)
// return x.a - y.a
// })
// console.log(l)
//箭头函数不能作为构造函数,也就是不能new,因为1.没有自己的this;2.没有prototype
let fn = ()=>{}
console.dir(fn)
</script>
</body>
</html>
js箭头函数相关的知识
最新推荐文章于 2022-07-07 15:07:07 发布