Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does this mean?: x || x === {}

Tags:

javascript

Does the following:

x || x === {}

not mean !!x, that is, x is defined?

like image 554
Baz Avatar asked Oct 14 '16 13:10

Baz


1 Answers

That comparison makes no sense, because either x is truthy, then you get the result of x, or falsy, you get false (a falsy value is never strict equal to an empty object instance).

A concise version would be

x || false

for give me x or false.

like image 88
Nina Scholz Avatar answered Sep 28 '22 06:09

Nina Scholz