问题描述
我是JavaScript新手,这是我的第一个问题 堆栈溢出,如果我错过了哪些内容,请告诉我 应该包含在问题中。
问题1: 谁能解释为什么有时控制台输出序列与 调用它们的顺序( myFunction(); 和 messageLogger(); )。
<!DOCTYPE html>
<html lang="en">
<head>
<Meta charset="UTF-8">
<Meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>Test Page</title>
</head>
<body>
<script>
let myFunction = function messageLogger() {
console.log('Message Logged');
}
myFunction(); //Should output message in console
messageLogger(); //Should generate error in console
</script>
</body>
</html>
这是上面和图像Original Code Image中所示的基本函数表达式代码。
此代码应在运行 myFunction(); 后在控制台中显示错误,如镜像Console Output Image 1所示,但有时在运行 myFunction(); 之前,会显示错误。在图像Console Output Image 2中。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)