A few days ago colleagues said that the array of slice method in the IE8 with compatibility issues, I consulted the MDN, the document contains IE8 and the following browser, Dom object composed of a pseudo-array call slice method does not follow the standard behavior
I made a demo and I tested it on the IE8.
<div> Ancient </div><div> German </div><div>God</div><script>var dom = document.getElementsByTagName ("div"); Console.log (Array.prototype.slice.call (DOM,1) ) < /script>
Results
Tip Dom is not a JS object in ie9+ browser without this problem. MDN Official document also gives a piece of code solution, I have a quick and easy way to solve the problem. Since DOM is not a JS object, turn it into an object is not finished, so I put the code to do the following transformation:
<div> Ancient </div><div> German </div><div>God</div><script>var dom = document.getElementsByTagName ("div"); Console.log (Array.prototype.concat.apply ([],dom). Slice (1)) </script>
Compatibility problem is so happy to solve the ~
The Goody God
Source: Http://www.cnblogs.com/wangmeijian
This article copyright belongs to the author and blog Garden All, welcome reprint, reprint please indicate source.
If you feel that this blog post for your gain, please click on the bottom right corner of the [recommended], Thank you!
IE8 and the following browser pseudo-array slice method compatible processing