I've noticed that the following results hold:
1 in [1,2,3] == true
['a','b','c'].includes('a') == true
But
'a' in ['a'] == false
This happens in both node and the browser.
Why? Can someone link me an article to read more about it?
I've noticed that the following results hold:
1 in [1,2,3] == true
['a','b','c'].includes('a') == true
But
'a' in ['a'] == false
This happens in both node and the browser.
Why? Can someone link me an article to read more about it?
The experiment worked but only coincidentally. The key 1
existed in the array because the array happened to be 3 items long. So, the below wouldn't work:
4 in [4,5] == false
And the below would work:
1 in ["a","b"] == true