We Recommend

Pro JavaScript Techniques Pro JavaScript Techniques
Pro JavaScript Techniques is the ultimate JavaScript book for the modern web developer. It provides everything you need to know about modern JavaScript, and shows what JavaScript can do for your web sites. This book doesn't waste any time looking at things you already know, like basic syntax and structures.


Posted By

Leech on 07/21/06


Tagged

object equals compare


Versions (?)


Who likes this?

1 person has marked this snippet as a favorite

jkochis


Equals v1.0


Published in: JavaScript 


URL: http://jsfromhell.com/geral/equals

Tests if two or more objects are equal, accepts any type of object, even multidimensional arrays. Created: 2005.12.26

  1. /**************************************
  2. * Jonas Raoni Soares Silva
  3. * http://www.joninhas.ath.cx
  4. **************************************/
  5.  
  6. equals = function(a, b){
  7. for(var j, o = arguments, i = o.length, c = a instanceof Object; --i;)
  8. if(a === (b = o[i]))
  9. continue;
  10. else if(!c || !(b instanceof Object))
  11. return false;
  12. else for(j in b)
  13. if(!equals(a[j], b[j]))
  14. return false;
  15. return true;
  16. };

Report this snippet 

You need to login to post a comment.