Javascript compare

Comparing two arrays in JavaScript using either the loose or strict equality operators (== or ===) will most often result in false, even if the two arrays contain the same elements in the same order. This is due to the fact that arrays and objects are compared by reference and not by value in JavaScript, which means this solution does not produce the desired result:


const a = [1, 2, 3];
const b = [1, 2, 3];

a === b; // false

Popular Javascript compare articles and code snippets

Related Articles

js interview questions