What will be the result of following code?

var a = [];
console.log((a == a) + ' ' + (a == !a));
Explanation
(a == a) - we compare link to itself and result is true. (a == !a) - second operand "!a" converted to the boolean and thus generates conversion to boolean "a". [] == false // empty array == false ![] == false // link to array object with ! operator == false that is means [] == ![] // true

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback