bind方法使用案例

论坛 期权论坛 脚本     
已经匿名di用户   2022-2-7 16:32   2537   0
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>bind的使用方法</title>
</head>
<body>
    <script>
        //bind方法使用案列
        
        function A(){
          console.log('----------');
          return this;
        }
        
        function B(){
          var obj = {
             name:'hello word',
             parm:arguments || null
          }
          return obj;
        }

        function C(parm){
          var b = B(parm);
          return A.bind(b,null);
        }
        
        //调用
        var c = C([1,2,3])();

        for(i in c){
          if(typeof c[i] == 'object'){
             for(var j in c[i]){
                console.log(c[i][j])
             }
          }else{
             console.log(c[i])
          }
        }
    </script>
</body>
</html>

转载于:https://www.cnblogs.com/zhujiasheng/p/8427840.html

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:81
帖子:4969
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP