question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[...Array(5).keys()] not working in Android

See original GitHub issue

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

Yes

Environment

OS: macOS Sierra 10.12.6 Node: 9.8.0 Yarn: 1.5.1 npm: 5.6.0 Watchman: 4.7.0 Xcode: Xcode 9.2 Build version 9C40b Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed) react: ^16.3.0-alpha.1 => 16.3.0-alpha.2 react-native: 0.54.2 => 0.54.2

Steps to Reproduce

console.log([...Array(2).keys()]) does not produce [0, 1].

  1. Run https://snack.expo.io/SJT6PCPPZ on Android (works)
  2. Run https://snack.expo.io/H1elODwPb on Android (nothing rendered on screen) Additional note: both works on iOS.

Expected Behavior

https://snack.expo.io/H1elODwPb should render data on screen

Actual Behavior

https://snack.expo.io/H1elODwPb renders nothing on screen

Reproducible Demo

see above

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:7
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
sonayecommented, Jul 13, 2018

Workaround:

Array(5).fill().map((_, index) => index)
3reactions
hramoscommented, Mar 23, 2018

You’re using a different JavaScript engine when remote JS debugging is turned on - possibly Chrome’s (V8).

Read more comments on GitHub >

github_iconTop Results From Across the Web

JS: Array has no method 'keys' (Cordova, Android)
FWIW I get the same output from let data = Array.from(Array(20), new_datum); as I do let data = Array.from(Array(20).keys(), new_datum); if that ...
Read more >
Array.prototype.keys() - JavaScript - MDN Web Docs
The keys() method returns a new Array Iterator object that contains the keys for each index in the array. Try it.
Read more >
What is [...Array().keys()] : r/learnjavascript - Reddit
Calling .keys() returns an iterator, which lets you iterate over the key values. Important thing at this step is it doesn't return an...
Read more >
SparseArray - Android Developers
Note that this container keeps its mappings in an array data structure, using a binary search to find keys. The implementation is not...
Read more >
Array | Apple Developer Documentation
If you need an array that is preinitialized with a fixed number of default values, use the Array(repeating:count:) initializer. var digitCounts = Array( ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found