Consider following code snippet:

var a = []; 
var b = [];
console.log((a == b) + ' ' + (a == !b) + ' ' + (!a == b)+ ' ' + (!a == !b));
What will be printed to the console?
Explanation
a == b // false, because they are different array objects. In all other examples Javascript interpreter will do type-convert: !object -> !true -> false -> 0 object -> empty array -> 0 which will lead to comparison 0 == 0, which gives true. In case if one of the array was not empty, for example var a = [1], then second and third comparison would be converted to 1 == 0, and that will result false.

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Cosmo
Зареєструйся Зараз
або Підпишись на майбутні тести