函数 Declaration 对比表达式
单选题 中等
题目
什么是 键 difference 之间函数 declaration and 函数表达式?
提示
Think 关于当 你能 call 函数相对到 哪里它 appears in code.
解释
Function declarations (e.g., function foo() {}) are fully hoisted — you can call them before they appear in the code. Function expressions (e.g., const foo = function() {}) are not hoisted as functions — the variable is hoisted but not the function value, so calling before the line throws an error.
相关资源
相关课程
- JavaScript 函数
学习关于函数 declarations and 表达式.
查阅不认识的术语
新手友好的术语表用大白话解释编程术语——变量、函数、DOM、Promise 等等。
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。
动手做项目
通过引导式项目应用所学,含起始代码与解决方案。