zoukankan      html  css  js  c++  java
  • 文章标题

    1、考察点call、apply

    var a = Function.prototype.call.apply(function(a){ return a; }, [0,4,3]);
    console.log(a);  // 4

    分解:

    (Function.prototype.call).apply(function(a){ return a; }, [0,4,3]);

    注意:fun.apply(obj, args)等价于obj.fun(args)

    故上面的表达式可以改为

    (function(a){ return a; }).call(0, 4, 3);

    call的第一个值为要绑定作用域,后面为参数

    相当于,

    (function(a, b){ return a; }).call(0, 4, 3); // 0为绑定的作用域(可忽略),a=4, b=3
  • 相关阅读:
    053364
    053363
    oracle导出批量表N行记录
    053362
    053361
    053360
    053359
    053358
    053357
    053356
  • 原文地址:https://www.cnblogs.com/Zting00/p/7497630.html
Copyright © 2011-2022 走看看