我不敢肯定我目前的执行情况:
function isNodeList(nodes) {
var result = Object.prototype.toString.call(nodes);
// modern browser such as IE9 / firefox / chrome etc.
if (result === [object HTMLCollection] || result === [object NodeList] ) {
return true;
}
//ie 6/7/8
if (typeof(nodes) != object ) {
return false;
}
// detect length and item
if (!( length in nodes) || !( item in nodes)) {
return false;
}
// use the trick NodeList(index),all browsers support
try {
if (nodes(0) === null || (nodes(0) && nodes(0).tagName)) return true;
}
catch (e) {
return false;
}
return false;
}
A common situation is {length:1,item:function(){return [];}}
The value of result in chrome / safari / opera is [object NodeList] .
In firefox and IE 9 , it is [object HTMLCollection] .
标准价值是什么?