Run ❯
Get your
own
website
Result Size:
625 x 565
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <body> <h2>JavaScript Hoisting</h2> <p>With <b>const</b>, you cannot use a variable before it is declared:</p> <p id="demo"></p> <script> try { alert(carName); const carName = "Volvo"; } catch (err) { document.getElementById("demo").innerHTML = err; } </script> </body> </html>