As far as I know, logical && works as follows
var test = false; var foo = test && 42;
This code assigns 42 foo only if the first condition evaluates to true . Therefore, in this example, foo will keep the current value.
I am wondering why this snippet doesn't work at all:
var test = ""; var foo = test && 42;
Now foo gets the value from test . I am very confused. An empty line is one of the values โโof the Javascript fake, so why the && operator could not execute this script?
Can someone help me with the spec on this, please?
source share