Sri walks the train looking for x: indexOf and includes compare in different ways. See what each says about NaN, -0, holes in the train and wagon 0. An…
The key idea
indexOf uses ===, includes uses SameValueZero
Try it in this playground
Look for NaN with indexOf, then includes Watch Sri walk past NaN with ===, then find it with SameValueZero.
Use the > 0 check on wagon 0 indexOf gives 0, and 0 > 0 is false.
Look for a box with the same contents, then arr[0] A new box is not found; the very same box is.
Try an empty slot Write [1, , 3] and look for undefined: indexOf skips the slot, includes reads it.