CodeLab
Show Output
 
xxxxxxxxxx
17
 
1
<!DOCTYPE html>
2
<html lang="en">
3
<head>
4
    <meta charset="utf-8">
5
    <title>JavaScript Function Hoisting</title>
6
</head>
7
<body>
8
    <script>
9
    // Calling function before declaration
10
    sayHello(); // Outputs: Hello, I'm hoisted!
11
    
12
    function sayHello() {
13
        document.write("Hello, I'm hoisted!");
14
    }
15
    </script>
16
</body>
17
</html>
 

在微博、微信、公众号、小程序分享此示例。 如果您觉得有帮助,请给我们一个赞。