Introduction about JavaScript

Last Updated on April 22, 2022
Introduction about JavaScript

An Introduction to JavaScript.

JavaScript is one of the popular programming languages in the software developer world. It is one of the essential programming languages for any software developer. You can also say that without knowing the JavaScript programming language, there would be impossible to become a software developer. JavaScript is easy to learn, and it is fun to work with this amazing programming language.

JavaScript initially runs in the web browser, primarily for the client-side scripting language. But nowadays, JavaScript can also run on the server-side or out of a web browser with the help of Node.js.

JavaScript is a dynamic, object-oriented, prototype-based programming language that is most known as the scripting language for Web pages. It has also been widely used as a general-purpose programming language.

JavaScript was initially developed in 1995 by Brendan Eich to provide an interpreted, lightweight, and cross-platform scripting language that would be more suitable than Java for what was then called the "World Wide Web." JavaScript is one of the top languages in use on websites today.

How to implement JavaScript code on our website?

There is various way to integrate JavaScript into your website. Let's see about it in detail with an example.

JavaScript can be used with HTML tags.


<!DOCTYPE html>
<html>
<head>
<script>
Your JavaScript can be here...
</script>
</head>
<body>

<script>
Your JavaScript can be here...
</script>

</body>
<script>
Your JavaScript can be everywhere...
</script>
</html>

As you can see in the above example, JavaScript code is written in the HTML head tag, inside the body tag, and even after the body tag. It can be integrated anywhere on your website.

JavaScript is also written in a separate file and integrated within your webpage.

Let's see another example of how we can create and use an external JavaScript file. Let's assume that you have created the separate JavaScript and named it the myJavaScript.js file. Remember the extension of the file must be (<strong>yourscriptname.js</strong>).

myJavaScript.js

Your JavaScript code can be written here...
You can integrate the script file into any webpage.

<!DOCTYPE html>
<html>
<head>
<script src="myJavaScript.js"></script>
</head>
<body>

<script src="myJavaScript.js"></script>

</body>
<script src="myJavaScript.js"></script>
</html>

As you can see in the above example, first we have the separate script file and then we integrate it into the HTML files same as we saw in the first example. Instead of writing the code inside of the HTML script tag, we have separated it out into different files and called it in the web page file.