Lorenzo Lorenzo - 1 year ago 65
Javascript Question

What is the "===!" operator doing?

I'am playing with some JavaScript and found something strange.

This code alerts "false" but gives no syntax errors. Someone could explain why adding one or even many

is no resulting with any errors ?

var i = void 0;
var b = i ===! void 0 ? "true" : "false";
alert(b);//display false but no syntax errors..

Answer Source

Whitespace means nothing so it is

var b = (i === (!void 0))  ? "true" : "false";

which is

var b = (i === true) ? "true" : "false";

MDN Operator Precedence

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download