Javascript Data types
JavaScript variables can hold many data types: numbers, strings, objects and more:
var length = 16; // Numbervar lastName = "Johnson"; // Stringvar x = {firstName:"John", lastName:"Doe"}; // Object
<p>When adding a number and a string, JavaScript will treat the number as a string.</p>
<p id="demo"></p>
<script>
var x = 16 + "Volvo";
document.getElementById("demo").innerHTML = x;
</script>
var length = 16; // Numbervar lastName = "Johnson"; // Stringvar x = {firstName:"John", lastName:"Doe"}; // Object
An example:
<h2>JavaScript</h2><p>When adding a number and a string, JavaScript will treat the number as a string.</p>
<p id="demo"></p>
<script>
var x = 16 + "Volvo";
document.getElementById("demo").innerHTML = x;
</script>
JavaScript
When adding a number and a string, JavaScript will treat the number as a string.
0 коммент.