zoukankan      html  css  js  c++  java
  • js call理解

    function fn1(){console.log(1);}

    function fn2(){console.log(2);}

    fn1.call.call.call.call(fn2); //=>fn2() =>2

    解释:

    fn2.call( fn1 ) => fn1.fn2() 

    fn1.call=>function call() { [native code] }

    fn2.call === fn1.call = Function.call,

    Function.call.call( fn2 ) => fn2.call() => fn2() //2

    fn1.call.call.call.call(fn2)== Function.call.call.call.call(fn2)//2

    =》Function.call.call.+n+.call.call(fn2)//2

    =》Function.call.call( fn2 )//2 js运行模式

    =》fn2.call()//2

    =》fn2()// this === null 或 windows

    Function.call(fn2)//chrome =>function anonymous() {}

    Function(fn2)  //function anonymous() {function fn2(){console.log(2);}}

  • 相关阅读:
    css定位
    css盒子
    css元素分类
    Css属性
    Css基础2
    啊啊啊啊
    函数指针
    重载函数
    成员函数
    资源网站
  • 原文地址:https://www.cnblogs.com/ftxc/p/4644893.html
Copyright © 2011-2022 走看看