Well, I need to check the contents of 2 objects, I need to know if they are the same or not in the main fields.
My idea is to check when inserting some data in the localStorage if that data already exists, if there is I should replace the existing object in the array of locaStorage, if not I need to create.
Example:
Object1 {TXT_NOMEX_PESSO: "Renan Rodrigues Moraes", COD_IDENT_PESSO: "9999160307115906859", FLG_IDENT_PESSO: "L", FLG_STATU_PESSO: "A", FLG_STATU_PARTC: "A"…}
Object2 {TXT_NOMEX_PESSO: "Lidiane Morais", COD_IDENT_PESSO: "9999160307134108952", FLG_IDENT_PESSO: "L", FLG_STATU_PESSO: "A", FLG_STATU_PARTC: "A"…}
Object3 {TXT_NOMEX_PESSO: "Renan Rodrigues", COD_IDENT_PESSO: "9999160307115906859", FLG_IDENT_PESSO: "L", FLG_STATU_PESSO: "A", FLG_STATU_PARTC: "A"…}
If I enter the Object1
and soon after the Object2
it would enter normal, because there would be no, if I inserted the Object3
it should replace the Object1
with the Object3
.
I need to do this as simply as possible, if any. The method I know to do this is to go through each tuple of chave : valor
and check whether it is the same or not.
I forgot to tell you something very important, as this is all about localStorage
I need to know if it exists or not, that is, I am not always sure that I will have 2 objects equal.