How to convert a collection to an array in javascript

You can do this:

var coll = document.getElementsByTagName('div');

var arr = Array.prototype.slice.call( coll, 0 );

EDIT: As @Chris Nielsen noted, this fails in IE pre-9. Best would be to do some feature testing, and create a function that can handle either, or just do a loop as in the (second) solution from @brilliand.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)