I am currently using the Chrome console to do some debugging for a Greasemonkey script.
From the console I run var opp = document.querySelectorAll(\'a[class=\"F-re
Yes, this is because the result of querySelectorAll
is a node list, not an array. You can apply the slice method of Array
to a node list, however:
Array.prototype.slice.call(op, 0, 1);
This works more or less as expected, because a NodeList
"quacks" in just the way slice
expects, i.e. it contains elements indexed sequentially. However, you should be wary of using this in general; it is much safer to simply iterate over the NodeList
.