Guest User

Untitled

a guest
Jun 21st, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. <p>@tobie langel - I rewamped your code, and it seems to work fine now.<br />
  2. @dean - I'm using this approach instead of yours. As I tested, it's roughly 50x faster (ie6)</p>
  3. <pre class="javascript">
  4. function log(value) {
  5. document.body.innerHTML += value;
  6. };
  7.  
  8. function iterate(array) {
  9. if (array.length) {
  10. try { array.shift()(); }
  11. finally { iterate(array); }
  12. }
  13. };
  14.  
  15. iterate([
  16. function() { log(0); },
  17. function() { log(1); throw new Error; },
  18. function() { log(2); },
  19. function() { log(3); throw new Error; }
  20. ]);
  21. </pre>
Add Comment
Please, Sign In to add comment