codescracker


javascript

JavaScript Statements



« Previous Tutorial Next Tutorial »


JavaScript statements are basically instructions that is to be executed by the web browser.

Here is an example. In this example, the statement, document.getElementById("statement_para1").innerHTML = "Hello JavaScript Statements!"; tells the browser to write Hello JavaScript Statements! inside the HTML element having id, "statement_para1".

<!DOCTYPE html>
<html>
<head>
	<title>JavaScript Statements Example</title>
</head>
<body>

<p id="statement_para1"></p>
<script>
	document.getElementById("statement_para1").innerHTML = "Hello JavaScript Statements!";
</script>

</body>
</html>

Here is the output produced by the above JavaScript statement example:

javascript statements

In the above JavaScript program, the

document.getElementById("statement_para1").innerHTML = "Hello JavaScript Statements!";

is a statement in JavaScript.

Every JavaScript programs may contains one or more than one statements.

JavaScript Semicolons (;)

Every executable statement must ends with a semicolon in JavaScript. Here is an example:

var a = 50; var b = 50; var c = a + b;

JavaScript White Spaces

JavaScript ignores multiple spaces. So, you are free add requred number of white space to your script to make it more readable. Here is an example. The given two statements are equavalent to each other in JavaScript:

var employee1 = "Prashant";
var employee2="Prashant";

« Previous Tutorial Next Tutorial »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test