请教call语法

samuelpan 2006-10-31 03:51:10
a.b.c=function(container,config){
a.b.c.superclass.constructor.call(this,container);
.....
}

请问上面第2句是什么意思。
从语法角度以及从为什么要这样写的角度来说明一下。谢谢!
...全文
150 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
samuelpan 2006-10-31
  • 打赏
  • 举报
回复
慢慢体会中...

问题是a.b.c是相同的。即obj1=obj2这种情况,这样写有什么实际用处呢
PaulLeder 2006-10-31
  • 打赏
  • 举报
回复
obj1.method1.call(obj2,arguments)
就是把对象obj1的方法merthod1绑定到对象obj2上用
hbhbhbhbhb1021 2006-10-31
  • 打赏
  • 举报
回复
说简单些就是可以传很多个参数,从第二个参数开始都是函数的参数,第一个是调用该函数的对象,而call前面的则是函数的名字
Apq001 2006-10-31
  • 打赏
  • 举报
回复
自己说还真不好说,看MSDN吧,重点要先理解object context:
Calls a method of an object, substituting another object for the current object.

call([thisObj[, arg1[, arg2[, [, argN]]]]])
Arguments
thisObj
Optional. The object to be used as the current object.
arg1, arg2, , argN
Optional. List of arguments to be passed to the method.
Remarks
The call method is used to call a method on behalf of another object. The call method allows you to change the object context(要好好理解它) of a function from the original context to the new object specified by thisObj.

If thisObj is not supplied, the global object is used as thisObj.

87,904

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧