Javascript Under The Hood
Javascript is a lightweight programming language. It has been around a long time. In this article, I will be giving giving a high level overview of Javascript, how it evolved and you can use it to build real world systems.
Table Of Contents
History Of Javascript
Javascript was initially developed to add dynamic behavior to static web pages. It was developed as a scripting language by Netscape around the year 1995. It’s interpreter was shipped along with the Netscape Navigator browser. Over the years, it was adopted by other browsers like Internet Explorer. Google also released its Chrome browser with the Javascript engine.
Early usage of Javascript
As mentioned earlier, Javascript was initially developed to add dynamic behavior to static web pages. The Javascript engine is shipped as part of the browser. So it integrates with HTML and executes in the browser. It was primarily used for client side validations. So for example, if you have an HTML form that accepts a phone number, you can use client side Javascript that checks if the phone number is valid. So you can put some basic checks that validate if the entered value has only numbers and not letters or other symbols. Only if the client side validation is successful, the value can be sent to the server side for appropriate processing.
Current Javascript Ecosystem
Over the years, several third party Javascript frameworks and libraries were developed. These made it possible to add more and more functionality on the client side. Some of the things that you can do with Javascript are now loading new content into a page without refreshing the page, interactive content, animating page elements, etc. Some of the most popular Javascript libraries and frameworks are Angular (Open source framework developed by Google), React (Created by Facebook for its website but was later made open source), jQuery (popular Javascript library), among others.
In addition, it is also now possible to use Javascript on the server side via frameworks like node.js.
How Server side Javascript works
Traditionally, Javascript was used on the client side. The server side processing like database handling and other business logic was developed using other server side frameworks like PHP or JSP or ASP. However, the advent of Node.js changed all this. Node.js is open source. It allows running Javascript applications outside a browser. So it provides a runtime environment to run Javascript applications. In addition, it also provides several Javascript libraries. This makes it possible to use Javascript to develop server side code as well.
The main advantage of Node.js over traditional server side libraries is that it is asynchronous. So once it receives the request, it does not wait for the request to be processed, it is ready to receive the next request.
Conclusion
In its early years, Javascript was used only to perform client side validations. However, over the years a number of Javascript frameworks have been developed. These make it possible to use Javascript for building complete applications. Not only that, it is also possible to use Javascript on the server side via frameworks like Node.js.