Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. function deepEquals(a, b) {
  2. if(a === b) {
  3. return true;
  4. }
  5.  
  6. if(a && b && typeof a === 'object' && typeof b === 'object' && Object.keys(a).length === Object.keys(b).length && Array.isArray(a) === Array.isArray(b)) {
  7. for(let key in a) {
  8. if(key in b) {
  9. if(!deepEquals(a[key], b[key]) {
  10. return false;
  11. }
  12. } else {
  13. return false;
  14. }
  15. }
  16. return true;
  17. }
  18.  
  19. return false;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement