Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // y and x can be whatever you look for equality
- function objeq(y,x)
- {
- var p;
- for(p in y) {
- if(typeof(x[p])=='undefined') {return false;}
- }
- for(p in y) {
- if (y[p]) {
- switch(typeof(y[p])) {
- case 'object':
- if (!objeq(y[p],x[p])) { return false; } break;
- case 'function':
- if (typeof(x[p])=='undefined' ||
- (p != 'equals' && y[p].toString() != x[p].toString()))
- return false;
- break;
- default:
- if (y[p] != x[p]) { return false; }
- }
- } else {
- if (x[p])
- return false;
- }
- }
- for(p in x) {
- if(typeof(y[p])=='undefined') {return false;}
- }
- return true;
- }
Add Comment
Please, Sign In to add comment