JavaScript Variables and Values
Learn how JavaScript variables hold values and see the result immediately in an editable browser example.
Basic
A JavaScript variable gives a value a name so your program can refer to that value later. Modern JavaScript commonly uses
let for values that may be reassigned and
const for bindings that should not be reassigned.
const language = "JavaScript";
let learners = 1;
learners += 1;
console.log(language);
console.log(learners);Edit and run the example
The HTML file provides the document, the CSS file provides its presentation, and the JavaScript file changes the document and writes to the example console. Try changing the values, then run the example.
Output
Ready to run.
What to notice
The variable name lets the program refer to a value without repeating the value itself.
The
letbinding can be reassigned.The JavaScript file can read and change elements in the HTML document.
Thanks for your feedback.
Mark this learning resource complete to track your learning progress.