Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

函数的arguments为什么不是数组?如何转化成数组? #139

Open
su37josephxia opened this issue Feb 25, 2022 · 1 comment
Open

Comments

@su37josephxia
Copy link
Owner

No description provided.

@shangjunhao
Copy link

为什么

BE 本人说法是当时设计 arguments 的时候只花了十天时间整理设计的太糙了, 后来本来也打算改成真的 Array, 但是后来觉得多一事不如少一事又不改了

后来因为 ES 要向后兼容, 如果改动的话牵扯太大(兼容性), 就不改了

直到 ES6 终于对 arguments 提供了一个替代品 - rest parameters:

怎么转化

Array.from(arguments)
Array.prototype.slice.call(arguments) 

引用

https://blog.csdn.net/weixin_30430169/article/details/94832480

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants