You are currently viewing JavaScript  A scripting language for webpages

JavaScript A scripting language for webpages

JavaScript Introduction

JavaScript is the most popular language. JavaScript is a client-side scripting language and it is also used for server-side development. JavaScript is embedded inside the HTML document. By adding scripts, we can make a more interactive webpage. We can do a dynamic update of the content of webpages, control multimedia, and make animations with the help of JavaScript. It is also supported by all the browsers like Chrome, Firefox, Safari, etc. which makes it the ultimate choice. Useful libraries and frameworks make JavaScript a high-performing programming language.

Now, JavaScript is embedded inside the Html file. Html stands for HyperText Markup Language. It is a markup language that is used to create the webpages. CSS stands for Cascading Style Sheets which is used to design the webpages. It makes the pages more interactive. JavaScript is used for the overall functioning of the webpages. It is used to modify website content and make it behave in different ways in response to a user’s actions for example when the user clicks on certain keys.

HTML is used to create the structure of the sites which is modified by other technologies like CSS and JavaScript to make it more interactive.

CSS is used to design the webpage, formatting, and layout.

JavaScript is used for making web pages alive, and to control the behavior of different elements.

History of JavaScript

JavaScipt was created in 1995 by Brendan Eich while he was working at Netscape Communications Corporation as an engineer. Netscape think about developing a client-side scripting language early as the web gained popularity and there is more demand for a client-side scripting language.
When initially client-side scripting language was created its name was Mocha. Then they called it LiveScript, which makes web pages alive. Then they named it JavaScript, at last, for advertising purposes because at that time JAVA was the most popular language. Finally, ECMAScript became its official name. But everyone calls it JavaScript.

How to add JavaScript to an Html file ?

JavaScript can be embedded in HTML file in two ways:

Internal JavaScript: We can add JavaScript inside the HTML file with the help of <script> tag.

Syntax:

<script>
//Body of the JavaScript
</script>

The <script> tag can either placed in <head> tag or <body> tag.

External JavaScript: We can make a separate JavaScript file with extension .js. And include it inside the html file with the help of <script> tag.

Syntax:

 <script src="//JavaScript file name"></script>
example:
<script src="s.js"></script> 
Here s.js is JavaScript file name.

Example of JavaScript

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Example of JavaScript</title>
</head>
<body>
    <h1 id="example">CodeShruta</h1>
    <button type="button" onclick='document.getElementById("example").innerHTML = "Welcome to the introduction of JavaScript"'>Click here</button>
</body>
</html>

Output:

After click on the Button the content of html gets changed from “CodeShruta” to “Welcome to the introduction of JavaScript”

Conclusion

JavaScript is the most popular scripting language. Before the creation of JavaScript, most websites were static, but JavaScript remove this limitation also. With the help of JS dynamic website was created. JavaScript is a very simple language but at the same time, it is very complex. Different libraries and frameworks made it more popular and easy to use.
Our upcoming JavaScript tutorial will help both students as well as professionals who want to make their websites dynamic and more attractive . If you don鈥檛 know basic HTML and CSS please learn them before moving to JS.

Thank you for reading!

Written by: Ankita Kataria

Check CSS tutorial here.
Ever heard about DevOps and how it is important for any software development?
Check this out DevOps.

This Post Has 2 Comments

Leave a Reply