Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function areEquals(json1, json2) {
- let comp1 = JSON.parse(JSON.stringify(json1));
- let comp2 = JSON.parse(JSON.stringify(json2));
- if (!(comp1.length === comp2.length)) {
- return false;
- }
- else {
- for (let el in comp1) {
- if (comp1.hasOwnProperty(el) && comp2.hasOwnProperty(el)) {
- if (comp1[el] instanceof Object && comp2[el] instanceof Object) {
- for (subEl in comp1[el]) {
- if (comp1[el].hasOwnProperty(el) && comp2[el].hasOwnProperty(el)) {
- if (comp1[el][subEl] !== comp2[el][subEl]) {
- return false;
- }
- }
- }
- }
- else {
- if (comp1[el] !== comp2[el]) {
- return false;
- }
- }
- }
- }
- }
- return true;
- }
Add Comment
Please, Sign In to add comment