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

怎样判断一个对象是否是数组,如何处理类数组对象 #210

Open
lgwebdream opened this issue Jul 6, 2020 · 3 comments
Open
Labels
JavaScript teach_tag 快手 company

Comments

@lgwebdream
Copy link
Owner

No description provided.

@lgwebdream lgwebdream added JavaScript teach_tag 快手 company labels Jul 6, 2020
@lgwebdream
Copy link
Owner Author

扫描下方二维码,获取答案以及详细解析,同时可解锁800+道前端面试题。

@dty999
Copy link

dty999 commented Jul 7, 2021

`展开运算符和Array.from()都可以将类数组转换成数组,也可以用for遍历`
Array.isArray =Array.isArray||function (arg) {
  return Object.prototype.toString.call(arg) === '[object Array]';
};

Array.isArray(arr)

@Kisthanny
Copy link

如何判断

  • Array.isArray()
  • xxx instanceof Array

如何处理类数组对象

  • Array.from(arguments)
  • Array.prototype.slice.call(arguments)
  • Array.prototype.concat.apply([], arguments)
  • [...arguments]

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

No branches or pull requests

3 participants