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)中受支持。

  • 相关阅读:
    PIE SDK介绍
    PIE软件介绍
    PIE SDK与Python结合说明文档
    转载博客(Django2.0集成xadmin管理后台遇到的错误)
    python+django学习二
    python+django学习一
    HTML练习二--动态加载轮播图片
    HTML练习一
    LeetCode 999. 车的可用捕获量
    LeetCode 892. 三维形体的表面积
  • 原文地址:https://www.cnblogs.com/johnnylion/p/3937442.html
Copyright © 2011-2022 走看看