gaoluyang
2 天以前 92230c9a97dc9ce9df3313d11d26999c04bb6b26
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
export default function isEqual(x, y) {
    if (x === y) {
        return true
    }
    if (!(x instanceof Object) || !(y instanceof Object)) {
        return false
    }
    if (x.constructor !== y.constructor) {
        return false
    }
    for (var p in x) {
        if (x.hasOwnProperty(p)) {
            if (!y.hasOwnProperty(p)) {
                return false
            }
 
            if (x[p] === y[p]) {
                continue
            }
 
            if (typeof (x[p]) !== "object") {
                return false
            }
 
            if (!Object.equals(x[p], y[p])) {
                return false
            }
        }
    }
    for (p in y) {
        if (y.hasOwnProperty(p) && !x.hasOwnProperty(p)) {
            return false
        }
    }
    return true
}