+ 1

#help Convert nodelist to array (javascript)

I want to convert node list to array using "Array.from(...)". The console say 'Array has no method from'. But in the tutorial video is work. Are sololearn doesn't support that method ?

17th Nov 2018, 1:35 PM
Zulfikar Ahmad
Zulfikar Ahmad - avatar
1 Odpowiedź
+ 1
It depends and would be more easily diagnosed if you brought the car (code) so the mechanics could look under the hood, per se. I haven't tried that specific method, but there's no reason for it to not work as far as I can see ( https://developer.mozilla.org/en-US/docs/Web/API/NodeList ). If I were to make a wild guess, it can only make an array if there are nodes to list, which consequently only happens after the nodes are loaded. In SoloLearn, the scripts are loaded before (at the beginning of) the document unless it is specifically deferred. A common mechanism to utilize would be window.onload. Providing a link to the relevant Code Playground project would be better though.
18th Nov 2018, 11:40 AM
Janning⭐
Janning⭐ - avatar