Title: A Common-Sense Guide to Data Structures and Algorithms, Second Edition Example: JavaScript == (page 91)

On page 91, there’s an example of an array intersection function that uses a double equals in its comparison line:

if (firstArray[i] == secondArray[j]) {

The code works, but using == in JavaScript was the cause of many difficult to debug errors and has been generally frowned upon for the past decade, with the occasional exception of using it to catch both undefined and null values.

Some linters completely prohibit == comparisons, so I’d suggest changing the line to use ===.

#book-a-common-sense-guide-to-data-structures-and-algorithms-second-edition

1 Like