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.

[Arrays] To convert an array-like object to an array, use Array.from

See original GitHub issue

In 4.3 you say to use the array operator to copy arrays.

Why not do the same for creating arrays 4.4?

const foo = document.querySelectorAll('.foo');
const nodes = [ ...foo ];

Obviously the title would need to change, but I think the syntax is more consistent with 4.3.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
kesnecommented, Sep 19, 2016

A wise man once told me that the last thing we should care about is performance.

1reaction
rileybrackencommented, Sep 19, 2016

Ah, now results are all over, I think I will just have to believe you 😉.

Here it is if you want to try it. http://jsbin.com/garayo/1/edit?js,console

Read more comments on GitHub >

github_iconTop Results From Across the Web

Array.from() - JavaScript - MDN Web Docs
An iterable or array-like object to convert to an array. mapFn Optional. Map function to call on every element of the array.
Read more >
Convert Array-like objects, Array.prototype.slice or Array.from
Array.prototype.slice.call has been the long-standing mechanism for converting array-like objects to arrays. If you are looking for browser ...
Read more >
How to Convert an Array-Like Object to an Array in JavaScript?
You can convert an array-like object into a JavaScript array in the following ways: #Using Array.from(). You can simply use Array.from() ...
Read more >
JavaScript Tutorial => Converting Array-like Objects to Arrays
JavaScript has "Array-like Objects", which are Object representations of Arrays with a length property. For example: var realArray = ['a', 'b', ...
Read more >
Converting array-like objects into arrays using ... - JavaScript Kit
Converting array-like objects into arrays using Array.from() method (ECMAScript 6) ... Array method for converting an array-like object into one of its own....
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