We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I am just trying this library for simple arrays and it's not working as I expected. This is the code:
const a1 = [2, 5, 8, 20]; const a2 = [5, 7, 9, 20]; const diff = detailedDiff(a1, a2); // this is the result // { added: {}, // deleted: {}, // updated: {0: 5, 1: 7, 2: 9} } // I was expecting this result // { added: {0: 7, 1: 9} // deleted: {0: 2, 1: 8} // updated: {}}
Can someone explain this result?
The text was updated successfully, but these errors were encountered:
It's because the keys of your 4-element array are the indexes 0–3, and none of them go away, they just change to contain different values.
In other words, the sequence of operations to get from [2, 5, 8, 20] to [5, 7, 9, 20] is—
[2, 5, 8, 20]
[5, 7, 9, 20]
a[0] = 5 a[1] = 7 a[2] = 9
—all of which are updates to existing indexes.
Sorry, something went wrong.
No branches or pull requests
I am just trying this library for simple arrays and it's not working as I expected. This is the code:
Can someone explain this result?
The text was updated successfully, but these errors were encountered: