解析器在向执行环境中加载数据时,对函数声明和函数表达式并非一视同仁.解析器会率先读取函数声明,并使其在执行任何代码之前可用(可以访问).至于函数表达式,则必须等到解析器执行到它所在的代码行,才会真的被解释执行.例子: alert (sum(10,10)); function sum (num1, num2) { return num1 + num2; } 以上代码完全可以正常运行.因为在代码开始执行之前,解析器就已经通过一个名为函数声明提升(function declaration hoisti…