Your Ad Here

Posted By

Piotrek290 on 02/25/10


Tagged

js try these


Versions (?)

Try.these(args)


 / Published in: JavaScript
 

  1. var Try = {
  2. these: function() {
  3. var a1;
  4.  
  5. for (var i=0; i<arguments.length; ++i) {
  6. var a2 = arguments[i];
  7. try {
  8. a1 = a2();
  9. break;
  10. } catch(e){}
  11. }
  12.  
  13. return a1;
  14. }
  15. };
  16.  
  17. // ============ Example
  18. Try.these(
  19. function() {return new ActiveXObject('Msxml2.XMLHTTP')},
  20. function() {return new ActiveXObject('Microsoft.XMLHTTP')},
  21. function() {return new XMLHttpRequest()}
  22. );

Report this snippet  

You need to login to post a comment.