Posted By

aulizko on 12/27/08


Tagged

textmate foreach object-detection ternar


Versions (?)

Ternar operator used to object-detection


 / Published in: JavaScript
 

  1. if (typeof ArrayUtilites == "undefined" || !ArrayUtilites) {
  2. var ArrayUtilites = {};
  3. }
  4.  
  5. ArrayUtilites.each = (Array.prototype.forEach) ?
  6. function (a, f, o) {
  7. Array.prototype.forEach.call(a, f, o || ArrayUtilites);
  8. return ArrayUtilites;
  9. } :
  10. function (a, f, o) {
  11. for (var i = 0, it; it = a[i]; i=i+1) {
  12. f.call(o || ArrayUtilites, it, i, a);
  13. }
  14. return ArrayUtilites;
  15. };

Report this snippet  

You need to login to post a comment.