You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The only correct way to compare would be to test type of each element then value, in a recurse manner, but it needs a very long line of code ;-) (eg lodash implementation
You can limit to the area where the code is valid with something like
// returns undefined when we can't decide in a such easy wayconstisEqual=(a,b)=>a.every((v,i)=>(['boolean','string'].includes(typeofv)||(typeofv==='number'&&!Number.isNaN(v)))) ? a.length===b.length&&a.every((v,i)=>v===b[i]) : undefined// or throw (which seems better in real life, because undefined is falsy and previous function can leads to bugs hard to detect)constisEqual=(a,b)=>a.length===b.length&&a.every((v,i)=>{if(['boolean','string'].includes(typeofv)||(typeofv==='number'&&!Number.isNaN(v)))returnv===b[i];throwError('isEqual can only compare array of boolean|string|number')})
The text was updated successfully, but these errors were encountered:
Hi,
You should alert that
isn't similar to
and both are valuable (and similar) only if all array elements are boolean|finite number|string
And the json comparaison can be dangerous
The only correct way to compare would be to test type of each element then value, in a recurse manner, but it needs a very long line of code ;-) (eg lodash implementation
You can limit to the area where the code is valid with something like
The text was updated successfully, but these errors were encountered: