Last Updated: September 09, 2019
·
674
· timuric

Convert node list to a true array

You can use slice method to convert list of html nodes to a true array

var divTags = Array.prototype.slice.call(document.querySelectorAll("div"));

Great article about small and nifty js tips:
http://tech.pro/tutorial/1453/7-javascript-basics-many-developers-aren-t-using-properly?utm_source=javascriptweekly&utm_medium=email

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside