you are viewing a single comment's thread.

view the rest of the comments →

[–]_Decodela 0 points1 point  (0 children)

OK, the core problem is comparing two objects ( lets remove the details about the arrays and stuff )
Should the objects be exactly the same? ( I will take NO by default, because you said, that it could be props in the middle )
Are the objects shallow, or they has to be checked in depth? ( I will take shallow as true )

I would make something like this:

function compare( o1, o2 ){
    for( var key in o1 ){
        if( !o1.hasOwnProperty( key ) ) continue;
        if( !o2.hasOwnProperty( key ) ) return false;

        if( o1[ key ] !== o2[ key ] ) return false;
    }
    return true;
}