functionfn(){
console.log('fn')}//回调函数functiontest(fn){setTimeout(()=>{fn()},1000);}test(fn)//闭包functiontest1(){let a ='aa';returnfunction(){
console.log('test1',a)}}test1()()//尾递归functiontest2(n,total){
‘use strict’;//函数参数不能有默认值、解构赋值、rest参数(扩展用算符...)if(n===1)return total;returntest2(n-1,n*total);}test2(5,1)//蹦床函数functiontest3(f){aif(f && f instanceofFunction){
f =f()}return f
}functionsum(x,y){if(y >0){return sum.bind(null,x+1,y-1);}else{return x;}}test3(sum(1,10))