为什么`function test(){} + 1;`的输出是1?

Why is the output of `function test(){} + 1;` is 1?

为什么下面代码的输出是1

function test(){} + 1; // output: 1

由于automatic semicolon insertion,该代码实际处理为:

function test(){}; + 1;

那就是 unary plus operator, not the addition operator

function test() or {} here is not an Object, its en empty statement and JS Cannot convert object to primitive value and find the safe route and convert this statement value to false.

{} + 1 = 1 because (false + 1) = always 1.