- 箭头函数的不适用场景
箭头函数不能使用 arguments、super 和new.target,也不能用作构造函数。此外,箭头函数也没有 prototype 属性
- 函数名的扩展
let test1 = function(){
cosnole.log(" this is test1 function")
}
test1() // ====> "this is test1 function"
let newTest = test1
test1 = null
newTest() // "this is test1 function"
test1() // not a function
说明:因为函数名就是指向函数的指针,所以它们跟其他包含对象指针的变量具有相同的行为。这意味着
一个函数可以有多个名称
- 函数传参的知识点
有个需求,需要一些传参数,但是,参数具体有多少个是不知道的。那这种情况需要如何解决呢?其实,每个函数里都会有 arguments 对象。我们可以从这个对象可以知道传入的参数个数了
let a = '参数1'
let b = '参数2'
let c = '参数3'
let d = '参数4'
function test(a,b,c,d){
console.log(arguments.length) // 4
console.log(arguments[0]) // '参数1'
console.log(arguments[1]) // 参数2
....
}