Q:

Why does new Array(3) == ",,"; return true

I found a weired question: new Array(3) == ',,';//true, and i don't know why is that.
I already know a number passed in function Array means to create a new specific length empty array, and I have no idea what ',,' mean? and I google it but no answer.
so I come to stack overflow, somebody may help me, I guess

A:

This is because the the toString() method is invoked on the array instance when you are comparing with the loose equality operator. The == operator uses the Abstract Equality comparison algorithm.
The operand on the left is being coerced to the type on the right of the == operator by calling the toString().
The toString() internally calls Array.prototype.join() on the array instance and since you have only holes in your array, the output is two commas as a string ,, :

//Outputs ,, to the console
console.log(new Array(3).toString()); 

//The toString() is calling join()
console.log(new Array(3).join() === new Array(3).toString());

If you do the same with the strict equality operator this won't be the case as type coercion won't happen:

//coercion is happening due to the loose equality operator
console.log(new Array(3) == ',,')  
 //strict equality does not call toString() on the Array as no type coercion happens
console.log(new Array(3) === ',,')

The toString() as I mentioned before calls the Array.prototype.join() so that is why you get ,, as the output of Array.prototype.toString().
The join() when called  without any parameters will join the elements of the array using the default separator ,. In case of an empty array it will join the holes with ,:

//This will also be true
console.log([1, 2, 3] == '1,2,3')

//toString() converts array to a string by joining with the default separator internally calling join()
console.log([1, 2, 3].toString() === '1,2,3')

//join() converts array to a string by joining with the default separator
console.log([1, 2, 3].join() === '1,2,3')

