-
函数的创建
-
函数的调用
-
函数的this指向
-
函数this指向的改变:
-
bind():捆绑函数,改变this,但不会调用函数,返回一个新函数,工作中常用,有的函数不需要立即调用,又想改变this指向,就可以使用bind()。比如,有一个按钮,点击后禁用,3秒后开启
-
call():调用函数,改变this,经常用于继承
-
apply():调用函数,改变this,返回一个伪数组,应用,例如调用数学内置函数
let arr=[1,22,33,44,55]
// this指向Math()
let max=Math.max.apply(Math,arr)
console.log(max)
//方法一
function fn(){
}
//方法二 匿名函数
let f=fn(){
}
//方法三:function()里的参数必须加引号
let f1=new Function('a','b'console.log(a+b))
f1(1,2)