Result may vary based on the number of iterations, browser, OS and external influences...
Usually Fast Duff's Device #2, #3, #4 runs faster when the number of iterations is bigger or when the test is executed multiple times without browser refresh - bitwise operations have a really strange behavior in JS, sometimes they are really fast and other times they run slower than the
Make sure you test each approach using real application code (since results may vary) and just use this kind of optimization if you really need it! Try to combine techniques and avoid property lookups!
PS: It's over 9000 iterations!
var iterations = 9999;
Ready to run.
|Fast Duff's Device #1
|Fast Duff's Device #2
|Fast Duff's Device #3
|Fast Duff's Device #4
|Fast Duff's Device #5
You can edit these tests or add more tests to this page by appending /edit to the URL.