The var statement declares a variable. - Javascript Data Type

Javascript examples for Data Type:var

Description

The var statement declares a variable.

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {//from www  .j a  va 2 s  .  c  o  m
    var lastName = "Bond";

    document.getElementById("demo").innerHTML = "Name: " + lastName;
}
</script>

</body>
</html>

Related Tutorials