There are ways to declare array.
- Array Constructor – new Array(arrayLength)
- Array Literal – 
let arrOne = ;
let arrTwo = ;
- console.log(arrOne == 8); // output => ?
- console.log(arrTwo == 9); // output => ?
- console.log(arrOne < arrTwo); // output => ?
So, Any guess what should be the output of all above statement.
Now, you know the answer is true, true, true. But why because it’s array and you are not comparing array value. Let me exlpain.
As it’s correct that array is different data type and number is different. And even if array compare with together they first converted during comparison.
Array Change In Comparison –
- console.log(“8” == 8); // output => true
- console.log(“9” == 9); // output => true
- console.log(“8” < “9”); // output => true
So, when equal is used then it only compare value not data type.
At last, That’s why we get an answer “true, true, true“.
Let me know in the comment section, what you think about it.
I hope you understand the concept and logic behind it.
But wait, i have something more for you –
- JS Quiz – can string split method will be limited
- JS Quiz – can array from method be like a map method
And last but not the least, don’t forget to like, comment and share. It gives us a morale boost to remain to continue. Also, join our Facebook Page
If you have any questions, please feel free to ask me in the comment section and also let me know if you have any suggestions. As suggestions are always welcome.