Message from JavaScript discussions

August 2020

— In array in checks for indexes and in object it checks for keys

— 

Coz,its checking for an index 2 in the first which isn't there so it returns false ?

Second case ? Why it's returning true as output ?

— Yes

— Second case there are 3 elements in the array hence index 2 exists

— But '2' is a string,right ?

Aren't we checking for a string '2' in the array ? #Confused.

— Coerced ?

— Array index is integer

— U prolly mix up Array.prototype.includes and the object key in operator

— In just controls if the key exists

In your example you got the VALUES 1 and 2, but they got keys which are 0 and 1

Message permanent page

— Thnx Mate!🤝

— Y do u do dis determin1st

— This is the explanation