Guest User

Untitled

a guest
Jun 20th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. function areEquals(json1, json2) {
  2. let comp1 = JSON.parse(JSON.stringify(json1));
  3. let comp2 = JSON.parse(JSON.stringify(json2));
  4.  
  5. if (!(comp1.length === comp2.length)) {
  6. return false;
  7. }
  8. else {
  9. for (let el in comp1) {
  10. if (comp1.hasOwnProperty(el) && comp2.hasOwnProperty(el)) {
  11. if (comp1[el] instanceof Object && comp2[el] instanceof Object) {
  12. for (subEl in comp1[el]) {
  13. if (comp1[el].hasOwnProperty(el) && comp2[el].hasOwnProperty(el)) {
  14. if (comp1[el][subEl] !== comp2[el][subEl]) {
  15. return false;
  16. }
  17. }
  18. }
  19. }
  20. else {
  21. if (comp1[el] !== comp2[el]) {
  22. return false;
  23. }
  24. }
  25. }
  26. }
  27. }
  28. return true;
  29. }
Add Comment
Please, Sign In to add comment