JavaScript Data Types

JavaScript variables can hold numbers like 100, and text values like "John Doe". In programming, text values are called text strings. JavaScript can handle many types of data, but for now, just think of numbers and strings. Strings are written inside double or single quotes. Numbers are written without quotes. If you put quotes around a number, it will be treated as a text string.

HTML file: Displayed by browser:
<body>
<h1>JavaScript Identifiers</h1>
<p>Strings are written with quotes.</p>
<p>Numbers are written without quotes.</p>
<h3>The JavaScript outputs:</h3>
<div id="demo"></div>
<div id="person"></div>
<div id="answer"></div>
<script>
   var pi = 3.14;
   var person ="John Doe"
   var answer = 'Yes I am!';
   document.getElementById("demo").innerHTML = pi;
   document.getElementById("person").innerHTML = person;
   document.getElementById("answer").innerHTML = answer;
</script>
</body>

JavaScript Identifiers

Strings are written with quotes.
Numbers are written without quotes.

The JavaScript outputs:

Remember: JavaScript identifiers are case-sensitive.

BackTable of ContentsNext