有人请解释这里发生了什么.
var y = 1;
if (function f(){return 'some text';}) {
y += typeof f;
}
console.log(y);// "1undefined"
Run Code Online (Sandbox Code Playgroud)
如果我把它改成函数表达式
var y = 1;
if (a = function f(){return 'some text';}) {
y += typeof a;
}
console.log(y);// "1function"
Run Code Online (Sandbox Code Playgroud)