The fastest way to convert NodeList to Array in JavaScript is to use the “Array.prototype.from()” method. The Array.prototype.from() method is used to create a shallow-copied new Array instance from an array-like or iterable object.
Syntax
let main_arr = Array.from(nodelist)
Example
let nodelist = document.querySelectorAll('div');
let main_arr = Array.from(nodelist);
console.log(main_arr);
for (let val of main_arr) {
console.log(val);
}
This is a straightforward way to convert a NodeList to an array and then process each element. If you run this code in a browser’s console on a webpage with div elements, you should see the array of div elements followed by each div element being logged.
Related posts
JavaScript ES6 Iterable to Array

Krunal Lathiya is a seasoned Computer Science expert with over eight years in the tech industry. He boasts deep knowledge in Data Science and Machine Learning. Versed in Python, JavaScript, PHP, R, and Golang. Skilled in frameworks like Angular and React and platforms such as Node.js. His expertise spans both front-end and back-end development. His proficiency in the Python language stands as a testament to his versatility and commitment to the craft.