I\'m not sure my current implementation is available all the time:
function isNodeList(nodes) {
var result = Object.prototype.toString.call(nodes);
/
I would structure the code differently:
function isNodeList(nodes) {
var stringRepr = Object.prototype.toString.call(nodes);
return typeof nodes === 'object' &&
/^\[object (HTMLCollection|NodeList|Object)\]$/.test(stringRepr) &&
(typeof nodes.length === 'number') &&
(nodes.length === 0 || (typeof nodes[0] === "object" && nodes[0].nodeType > 0));
}
Notes:
"item" is not mandatorily in a nodeListhasOwnProperty() instead of innodeType instead of tagName, as text nodes or comments do not have a name&& chain if you see fit