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

不使用loop,创建一个长度为100的数组 #7

Open
erbing opened this issue Apr 22, 2019 · 3 comments
Open

不使用loop,创建一个长度为100的数组 #7

erbing opened this issue Apr 22, 2019 · 3 comments

Comments

@erbing
Copy link
Owner

erbing commented Apr 22, 2019

不使用loop循环,创建一个长度为100的数组,并且每个元素的值等于它的下标

据说是 某宝的笔试题,大家可以试一试
@bq-hentai
Copy link

Object.keys((new Array(100)).fill(100))

@erbing
Copy link
Owner Author

erbing commented Apr 22, 2019

[...Array(100).keys()]

@alasq
Copy link

alasq commented Jun 28, 2019

Array.from({length:100},(i,j)=>j)

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

No branches or pull requests

3 participants