So, why the high failure rate? Simple: most browsers haven’t implemented arrays correctly their understanding of an array index and length is wrong. There are about thirty tests in all, and you should find that even the browser’s implementations fail a couple of tests (some fail substantially more.) The test page allows you to compare several library implementations to the browser’s built-in implementation, and mine. You can see how it fares on my push and pop test page. push = function () Īlways up for a challenge, I’ve tried to produce a bug-free implementation that conforms to the specification. Here are my functions (the > operator is explained later in the article): Array. In this article, I’ve documented the current problems, and I show how to write library implementations conforming precisely to the language spec’. It’s been seven years since the publication of the official ECMAScript Language Specification, and I think we should expect a little more from our browsers. These vary from browser to browser: Internet Explorer’s methods can’t be reused Safari has type-conversion issues and Firefox & Opera don’t truncate Arrays properly. While this is bad enough, I’ve also found that every browser’s implementation of push and pop contains bugs. However, literally every library’s implementation is flawed. Most JavaScript libraries include trivial implementations of Array’s push and pop methods to provide support for older browsers.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
January 2023
Categories |