zoukankan      html  css  js  c++  java
  • call 方法 (Function) (JavaScript)

    转载:http://msdn.microsoft.com/zh-cn/library/h2ak8h2y(v=vs.94).aspx

    调用一个对象的方法,用另一个对象替换当前对象。

    call([thisObj[, arg1[, arg2[,  [, argN]]]]])

    参数

    thisObj

    可选。 将作为当前对象使用的对象。

    arg1, arg2, , argN

    可选。 将被传递到该方法的参数列表。

    备注

    call 方法用于调用代表另一项目的方法。 它允许您将函数的 this 对象从初始上下文变为由 thisObj 指定的新对象。

    如果没有提供 thisObj 参数,则 global 对象被用作 thisObj。

    示例

    下面的代码演示如何使用 call 方法。

     1 function callMe(arg1, arg2){
     2   console.log('this value: '+ this);
     3   for (var i in callMe.arguments) {
     4     console.log('arguments: '+ callMe.arguments[i])
     5   }
     6 }
     7 
     8 callMe(1, 2);
     9 // this value: [object Window]
    10 // arguments: 1
    11 // arguments: 2 
    12 
    13 callMe.call('a', 'b', 'c')
    14 // this value: a
    15 // arguments: b
    16 // arguments: c 

    要求

    在以下文档模式中受支持:Quirks、Internet Explorer 6 标准模式、Internet Explorer 7 标准模式、Internet Explorer 8 标准模式、Internet Explorer 9 标准模式、Internet Explorer 10 标准模式和 Internet Explorer 11 标准模式。此外,也在应用商店应用(Windows 8 和 Windows Phone 8.1)中受支持。

  • 相关阅读:
    3.4.2内核下的I2C驱动
    AS3批量替换文件
    文件访问权限
    Windows快捷键
    整数与字符串之间的转换函数
    Windows获取文件大小
    Windows内核对象
    ASCII字符集
    IP协议
    获取真正的进程/线程句柄
  • 原文地址:https://www.cnblogs.com/johnnylion/p/3937442.html
Copyright © 2011-2022 走看看