为了账号安全,请及时绑定邮箱和手机立即绑定

apply第二个参数不是应该是个数组吗?对象也行吗?

apply第二个参数不是应该是个数组吗?对象也行吗?

MMTTMM 2018-10-19 14:11:48
如图
查看完整描述

1 回答

?
慕无忌1623718

TA贡献1744条经验 获得超4个赞

Syntax
fun.apply(thisArg, [argsArray])

Parameters

  • thisArg

The value of this provided for the call to fun. Note that this may not be the actual value seen by the method: if the method is a function in non-strict mode code, null and undefined will be replaced with the global object, and primitive values will be boxed.

  • argsArray

An array-like object, specifying the arguments with which fun should be called, or null or undefined if no arguments should be provided to the function. Starting with ECMAScript 5 these arguments can be a generic array-like object instead of an array. See below for browser compatibility information.

从es5开始支持array-like的object啦,所有array-like就是有length属性,有index作为key的object啦。
你这个object正巧就有length属性,不过没有键值对,所以遍历出5个undefined


查看完整回答
反对 回复 2018-11-15
  • 1 回答
  • 0 关注
  • 750 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信