Introduction to JavaScript

JavaScript is a client side scripting language, it makes our HTML pages dynamic and interactive.

We can write our script code directly into HTML document using <script> tag.

Syntax:

<script>
JavaScript code here
</script>

Let’s take some examples:

Example 1:

alert(): JavaScript alert() method is used to display an popup box with a specified message and OK button.

<html>
<head>
<title>Internal Script</title>
<script> alert(“Hello! Demo of alert box!”); </script>
</head>
</html>


Example 2:

document.getElementById(id): document.getElementById(id) method is often used to select HTML element.

<html>
<head>
<title>Html JavaScript</title>
</head>
<body>
<span id=”msg”></span>
</body>
<script>
document.getElementById(“msg”).innerHTML = “Welcome to JavaScript!”;
</script>
</html>


Case Sensitivity

JavaScript is a case sensitive language, so the variables, keywords, function names, and any other identifiers must always be written with a consistent capitalization of letters.

So the identifiers Date and DATE will convey different meanings in JavaScript.

Leave a Reply