It is very common to judge whether two js objects are completely the same in form pages. Next, let's share a piece of judgment code. If you are interested, refer to the following, I hope it will help you determine whether two js objects are identical when you create a form page.
Here is the solution on stackoverflow. Record it here.
The Code is as follows:
Object. prototype. equals = function (x)
{
Var p;
For (p in this ){
If (typeof (x [p]) = 'undefined') {return false ;}
}
For (p in this ){
If (this [p]) {
Switch (typeof (this [p]) {
Case 'object ':
If (! This [p]. equals (x [p]) {return false;} break;
Case 'function ':
If (typeof (x [p]) = 'undefined' |
(P! = 'Equal' & this [p]. toString ()! = X [p]. toString ()))
Return false;
Break;
Default:
If (this [p]! = X [p]) {return false ;}
}
} Else {
If (x [p])
Return false;
}
}
For (p in x ){
If (typeof (this [p]) = 'undefined') {return false ;}
}
Return true;
}