背景
    html文档解析的时候,是自上而下解析的,如果碰到了script标签,则会进行下载并执行了
    如果这个时候,我们的内嵌script标签里面有类似’’标签的字眼,会怎么样呢??
    如下:

    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
    6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    7. <title>test</title>
    8. </head>
    9. <body>
    10. <h1>哈哈哈</h1>
    11. <script>
    12. function fn() {
    13. console.log('</script>')
    14. }
    15. fn()
    16. </script>
    17. </body>
    18. </html>

    运行页面发生如下情况:
    image.png
    同时控制台报错:test.html:20 Uncaught SyntaxError: Invalid or unexpected token
    日常开发的时候可能无法遇到这种情况,但是了解一下总是没问题的哈