fe-notes icon indicating copy to clipboard operation
fe-notes copied to clipboard

变量名和函数名同名

Open Inchill opened this issue 3 years ago • 1 comments

Inchill avatar Nov 11 '22 06:11 Inchill

第一个链接文档中的函数 b 没有被修改为 20,是因为函数表达式标识符不可被修改,所以 b = 20 默认会失败,最后打印的 b 仍然是函数。

第二个链接文档中的变量和函数在预编译阶段存在变量提升,其中函数声明比变量声明更置顶(函数在变量上面),所以最后一次赋值后 a 不再是一个函数,执行的时候就会报错。

Inchill avatar Nov 11 '22 06:11 Inchill