xFactorSchool.com(Beta)
How to Do Examples
Python Examples
HTML Examples
Code Examples
C Code Examples
C++ Code Examples
C# Code Examples
Java Code Examples
Python Code Examples
HTML Code Examples
CSS Code Examples
JavaScript Code Examples
Online Editor
C Code Editor
C++ Code Editor
C# Code Editor
Java Code Editor
Python Code Editor
HTML Code Editor
CSS Code Editor
JavaScript Code Editor
Practice how to declare JavaScript variable
JavaScript Online Editor
Run Code
More JavaScript Sample Codes
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Declare JavaScript Variable in HTML</title> </head> <body> <h1>How to declare javascript varibable?</h1> <p>Variables in JavaScript are declared by using the var, let, or const keywords. 'const' is used to declare constants. Constant variable value cannot be reassigned or changed. </p> <p>var a = "JavaScript is ";</p> <p>let b = "a great ";</p> <p>const c = "fun.";</p> <button onclick="myFunction()">Click here to see result</button> <p id="myParagraph"></p> <!--Script tag is added to write JavaScipt code inside it--> <script> // declare variables using the var, let, or const keywords var a = "JavaScript is "; let b = "a great "; const c = "fun."; // const is used to declare constants, the value cannot be reassigned or changed. function myFunction() { document.getElementById("myParagraph").innerHTML = "a + b +c = " + a + b + c; } </script> </body> </html>