Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function deepCompare(o1, o2) {
- var o1t = typeof(o1), o2t = typeof(o2);
- if(o1t!==o2t){
- return false;
- }else{
- if((o1t!=='object' && o2t !=='object') || (o1==null || o2 == null)){
- return o1 === o2;
- }else{
- if(o1.length >= 0 && o2.length >= 0){
- if(o1.length === o2.length){
- return o1.every(function(i1, index){
- return deepCompare(i1, o2[index]);
- });
- }else{
- return false;
- }
- }else{
- if(!o1.length && !o2.length){
- var o1k = Object.keys(o1), o2k = Object.keys(o2);
- if(o1k.length !== o2k.length){
- return false;
- }else{
- return o1k.every(function(k){
- return deepCompare(o1[k], o2[k]);
- });
- }
- }else{
- return false;
- }
- }
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement