All You Need To Know About JavaScript

All You Need To Know About JavaScript

Are you interested in web development? Want to design some client-centric dynamic pages? If yes, then take a look at this article to know all about JavaScript language.

What is JavaScript?

JavaScript is an interpreted, lightweight programming language for the web. It is developed for crafting network-centric applications. This programming language is simple to apply as it can be easily integrated with HTML.

Javascript is supported by most of the browsers such as Internet Explorer, Firefox, Chrome, Opera, Safari and many more. JavaScript is mainly used for the enhancement of webpage to provide the best user experience to the users. It can also dynamically update the user interface and web page improvements such as 3D and 2D graphics, interactive maps, dialog and menus boxes, video players, and among others.

Prerequisites of JavaScript

To learn JavaScript, you should have a basic understanding of HTML language.

Uses of JavaScript

JavaScript is mostly used to develop interactive websites and basically used for:

  • Dynamic drop-down menus
  • Showing time and date
  • Client-side validation
  • Dynamic drop-down menus
  • Showing clocks
  • Displaying dialog boxes and pop-up windows

 

How to Load JavaScript into a Web page?

The simplest way to load the JavaScript in a web page is by using the script HTML tag.

  • First, load the external javascript file in your webpage as given below:

<script type=”text/javascript” src=”/path/to/javascript”></script>

  • If your javascript is from other domain then you can give the URL from the web page as mentioned below:

<script type=”text/javascript” src=”https://code.jquery.com/jquery-3.2.1.min.js”></script>

  • JavaScript can even be embedded in the HTML and it shows an alert box when it is loaded. The code for that is mentioned below:

<script type=”text/javascript”>

alert(“Page is loaded”);

</script>

History of JavaScript

The development of Javascript takes us back in the year 1995 when Netscape Communications commenced the development of Javascript. The developers tried to make the syntax of Javascript similar to Java as Java was quite popular at that time. In javascript the developers have amalgamated the functionality of SmallTalk and the syntax of Java. Originally, it was called Mocha in May 1995 but they changed its name to LiveScript in Sept 1995. But due to the popularity of Java language, it was renamed to Javascript in December 1995.

How Does JavaScript Work?

The working of JavaScript is very simple. Here are the steps that explicate how javascript works.

Step 1:

When your web page is loaded then HTML parser starts parsing the HTML to create the  DOM (Document Object Model).

Step 2:

When the parser come across a Javascript or CSS directive then it is handed over to the JavaScript engine or CSS parser as per the requirement.

Step 3:

After that JavaScript engine loads inline code and external JavaScript files but the code is not executed on an immediate basis. After the parsing of CSS and HTML, the javascript code is executed.

Step 4:

The code is executed as per they found on the web page like first the functions and variables are defined, then functions are executed and after that event handlers are triggered. Then, DOM gets updated by Javascript after these actions.

Final Word

These are some basic information about Javascript that will give you a rough sketch about this language.

Leave a Comment

%d bloggers like this: