An Introduction to JavaScript

Deepak Sharma
4 min readFeb 23, 2020
An Introduction to JavaScript by @dasjideepak

When most people start learning to code, they start with HTML and CSS. From there, they move on to JavaScript.

As we already learned in our previous blogs that the three elements together form the backbone of web development.

  • HTML defines the content of web pages or you can say that HTML defines the structure of a webpage.
  • CSS is used to style the appearance of content, for example, fonts or colors.
  • JavaScript provides the functionality to the website. Once you’ve created your website using HTML and CSS, JavaScript makes your site or project dynamic.

HTML & CSS are not considered as a programming language, while JavaScript is a programming language.

In this blog we will learn about JavaScript, JavaScript has become the most popular programming language for web developers today.

Topic Covered in this Blog :

1. What is JavaScript?
2. JavaScript History
3. Where is JavaScript Used?
4. What makes JavaScript Unique?
5. JavaScript Syntax
6. How to Link JavaScript to HTML?

What is JavaScript?

JavaScript is a scripting or programming language used primarily by Web browsers to create a dynamic and interactive experience for the user.

JavaScript was initially created to “make web pages alive”.

JavaScript History

In 1993, The first popular web browserMosaic” came into existence, later on, Netscape Navigator, both web browsers were designed by Marc Andreesen and his team, At that time, there was no functionality in the webpages, webpages could only be static, lacking the capability for dynamic behavior after the page was loaded in the browser, Marc Andreesen realized that the web needed to become more dynamic, they decided to add a scripting language to Navigator, so the company recruited Brendan Eich.

Javascript was developed by Brendan Eich for Netscape Navigator in 1995. JS was developed in just 10 days, It was originally named mocha, but quickly became known as “LiveScript”. But, due to trademark reasons and certain other reasons, in December 1995, the language was finally renamed to ‘JavaScript’.

Most people think that there is some connection between Java and JavaScript, but it is not true, JavaScript has no connectivity with Java programming language. The name was suggested and provided in the times when Java was gaining popularity in the market, JavaScript is a fully independent language with its own specification called ECMAScript.

Where Is JavaScript Used?

JavaScript is used across the web development stack. for both purposes, front end development and also back end development

JavaScript is used for :

  • Adding interactivity to websites — JavaScript was specifically developed to be a language embedded into a web browser and automate things on the client-side, such as displaying pop-up windows and dialog boxes (like an alert dialog box, confirm dialog box and prompt dialog box), validate form input before submitting to the server, etc.
  • Developing mobile applications — JavaScript isn’t just for websites… you can also create mobile apps using JavaScript. There are various JavaScript frameworks that can be used to build Android and iOS App.
  • Back end web development — JavaScript is mostly used on the front end of things, but it’s a versatile enough scripting language to be used on back end infrastructure, too.

What makes JavaScript unique?

There are at least three great things about JavaScript:
(i) Full integration with HTML/CSS.
(ii) Simple things are done simply.
(iii) Support by all major browsers and enabled by default.

JavaScript is the only browser technology that combines these three things. That’s what makes JavaScript unique. That’s why it’s the most widespread tool for creating browser interfaces.

JavaScript Syntax

JavaScript programs can be inserted into any part of an HTML document with the help of the <script> tag.

<!DOCTYPE HTML>
<html>
<head>
<title>JavaScript Demo by Deepak</title>
</head>
<body>
<!-- First JS Program -->
<script>
alert( 'Hello, world!' );
</script>
</body>
</html>

Here is the output of the above code:

How to link JavaScript to HTML

You can include JavaScript in your HTML in two ways:

  • Writing the code in your HTML
  • Including it as a link to an external file (External Script)

External Script

If we have a lot of JavaScript code, we can put it into a separate file.

Script files are attached to HTML with the src attribute:

<script src="file-pat.js"></script> 

We can give a full URL as well. For instance:

<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.2.0/lodash.js"></script>

--

--