I stumbled over this polyfill of Array.prototype.includes. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes. Is there a reason for the comparison of the variables with themselves on line 21,22?
if (searchElement === currentElement ||
(searchElement !== searchElement && currentElement !== currentElement)) {
return true;
}
Use scatterplots to compare two continuous variables. Use scatterplot matrices to compare several pairs of continuous variables. Use side-by-side box plots to compare one continuous and one categorical variable. Use variability charts to compare one continuous Y variable to one or more categorical X variables.
Use the equality operator to check if multiple variables are equal, e.g. if a == b == c: . The expression will compare the variables on the left-hand and right-hand sides of the equal signs and will return True if they are equal.
To check if a variable is equal to all of multiple values, use the logical AND (&&) operator to chain multiple equality comparisons. If all comparisons return true , all values are equal to the variable. Copied! We used the logical AND (&&) operator to chain multiple equality checks.
Yes, this second operand of the ||
does check whether both searchElement
and currentElement
are NaN
- the only value in JavaScript that is not ===
to itself. includes
is supposed to use the SameValueZero
equivalence algorithm, which is different from the the Strict Equality Comparison Algorithm (used by ===
) or the SameValue
algorithm (used in Object.is
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With