I'm declaring a function which is used as a comparison. My question is:
Why does the condition act as a statement?
why does line 4 work but not line 5?
I know this code is unrealistic and unused, but why does the compiler allow this syntax?
There is no answer on google. But then again, I might have not look in the right place.
var A = () => console.log(3);
if (A === console.log(1)) {
A();
};
A ? A() : null;
if (A === console.log(1567)) {};
if (B === console.log(1567)) {};
The expected output is:
3
The output is:
1
3
1567
Uncaught ReferenceError: B is not defined at :11:1
Aucun commentaire:
Enregistrer un commentaire