高阶函数

<!DOCTYPE html>
<html lang="Zh-cn">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //typeof instanceof
        var arr=[1,2,3,4,5];
        //console.log(typeof arr);//object
        //console.log(typeof {});//object
        // console.log(arr instanceof Array);//true
        // console.log({} instanceof Object);//true
        // console.log(arr instanceof Object);//true
       
        //call apply bind
        // console.log(Object.prototype.toLocaleString.call(arr))
        //.log(Object.prototype.toLocaleString.bind(arr))//返回的是函数的拷贝  如果要调用需加()
        //console.log(Object.prototype.toLocaleString.bind(arr)())

        //高阶函数
        // function f(){
        //     console.log("f()")
        // }

        //f()
        // function f(){
        //     return function(){
        //         console.log("f()")
        //     }
        // }
        // f()()
        //         console.log("f()")

        // function f(fun,fun2){
        //     btn.click=function(){
        //         fun()
        //         fun2()
        //     }
        // }
        // function sum(){
        //     console.log("sum")
        // }
        // sum();
        // f(sum)

        //回调地狱
        // function f(fun){
        //     fun();
        // }
        // f(f(f(f())))
        //Promise then

        //new Promise().then().then().then()解决回调地狱问题
    </script>
</head>
<body>
   
</body>
</html>
posted @ 2021-11-18 19:19  与神明画过押  阅读(28)  评论(0)    收藏  举报