Javascript and its use-case

Rajsoni
7 min readJun 25, 2021

What is JavaScript?

JavaScript is a scripting or programming language that allows you to implement complex features on web pages every time a web page does more than just sit there and display static information for you to look at displaying timely content updates, interactive maps, animated 2D/3D graphics, scrolling video jukeboxes, etc. you can bet that JavaScript is probably involved. It is the third layer of the layer cake of standard web technologies, two of which (HTML and CSS) we have covered in much more detail in other parts of the Learning Area.

Why JavaScript?

JavaScript is one of the 3 languages all web developers must learn:

1. HTML to define the content of web pages

2. CSS to specify the layout of web pages

3. JavaScript to program the behavior of web pages

What is JavaScript doing on your page?

Here we’ll actually start looking at some code, and while doing so, explore what actually happens when you run some JavaScript on your page.

Let’s briefly recap the story of what happens when you load a web page in a browser (first talked about in our How CSS works article). When you load a web page in your browser, you are running your code (the HTML, CSS, and JavaScript) inside an execution environment (the browser tab). This is like a factory that takes in raw materials (the code) and outputs a product (the web page).

A very common use of JavaScript is to dynamically modify HTML and CSS to update a user interface, via the Document Object Model API (as mentioned above). Note that the code in your web documents is generally loaded and executed in the order it appears on the page. Errors may occur if JavaScript is loaded and run before the HTML and CSS that it is intended to modify. You will learn ways around this later in the article, in the Script loading strategies section.

1. Web Applications

As day-by-day there is a continuous improvement in the browsers, so JavaScript gained popularity for making robust web applications. We can understand it by taking the example of Google Maps. In Maps user just requires to click and drag the mouse; the details are visible just by a click. There is a use of JavaScript behind these concepts.

2. Web Development

JavaScript is commonly used for creating web pages. It allows us to add dynamic behavior to the webpage and add special effects to the webpage. On websites, it is mainly used for validation purposes. JavaScript helps us to execute complex actions and also enables the interaction of websites with visitors. Using JavaScript, it is also possible to load the content in a document without reloading the webpage.

3. Mobile Applications

Now a day’s mobile devices are broadly used for accessing the internet. Using JavaScript, we can also build an application for non-web contexts. The features and uses of JavaScript make it a powerful tool for creating mobile applications. React Native is the widely used JavaScript framework for creating mobile applications. Using React Native, we can build mobile applications for different operating systems. We do not require writing different codes for the iOS and Android operating systems. We only need to write it once and run it on different platforms.

4. Game

JavaScript is also used for creating games. It has various libraries and frameworks for creating a game. The game can either be a 2D or 3D. Some JavaScript game engines such as PhysicsJS, Pixi.js help us to create a web game. We can also use the WebGL (web graphics library), which is the JavaScript API to render 2D and 3D images on browsers.

5. Presentations

JavaScript also helps us to create presentations as a website. The libraries, such as RevealJs, and BespokeJs, can be used to create a web-based slide deck. They are easier to use, so we can easily make something amazing in a short time.

The Reveal.js is used to create interactive and beautiful slide decks with the help of HTML. These presentations work great with mobile devices and tablets. It also supports all of the CSS color formats. The BespokeJS includes animated bullet lists, responsive scaling, and a wide variety of features.

6. Server Applications

A large number of web applications have a server-side to them. JavaScript is used to generate content and handle HTTP requests. JavaScript can also run on servers through Node.js. provides an environment containing the necessary tools required for JavaScript to run on servers.

7. Web Servers

A web server can be created by using Node.js. Node.js is event-driven and not waits for the response of the previous call. The servers created using Node.js are fast and don’t use buffering and transfer chunks of data. The HTTP module can be used to create the server by using the createServer() method. This method executes when someone tries to access the port 8080. As a response, the HTTP server should display HTML and should be included in the HTTP header.

In this article, we discussed various JavaScript applications. JavaScript has various other uses that help us to improve the performance of web pages. The other uses of JavaScript are listed as follows:

  • Client-side validation.
  • Displaying date and time.
  • To validate the user input before submission of the form.
  • Open and close new windows.
  • To display dialog boxes and pop-up windows.
  • To change the appearance of HTML documents.
  • To create the forms that respond to user input without accessing the server.

Microsoft

First off, Microsoft needs to work closely with JavaScript to built its Edge web browser. All browsers need to process and execute JavaScript efficiently, so Microsoft has developed and maintains its own JavaScript engine for Edge. Actually, there has been talking of them creating an alternate version of NodeJS with the Edge engine.

Recently, Microsoft has really embraced NodeJS. They thoroughly support Node on the Azure cloud platform. It's one of Azure’s major features, and they’ve integrated Visual Studio support for Node.

Microsoft has also developed a version of Node for Internet Of Things(IoT) applications. NodeJS is great for IoT because it’s lightweight and efficient.

PayPal

PayPal has obviously been using JavaScript on the front end of their website for a long time, but that’s only the beginning.

The online payment giant was one of the earliest adopters of NodeJS. During an overhaul of their account overview page, they decided to try building the page in Node at the same time as their usual Java development. The NodeJS version worked out so well, that they chose to use it in production and build all client-facing applications in Node going forward. That means that most of what you see in your account is running on Node.

PayPal even went as far as to create and maintain their own version of Express, called KrakenJS. It’s pretty obvious that they like JavaScript over at PayPal.

Uber

Uber needs to handle loads of data in real-time. They have millions of requests coming in continuously, and that does not just hit on a page. Uber needs to track driver locations, rider locations, and incoming ride requests. It has to seamlessly sort that data and match riders as fast as possible.

All of that plays to NodeJS’s and JavaScript’s strengths. Node is designed to handle requests and handoff data quickly. Its asynchronous capabilities are a huge part of that. Node is central to Uber’s user-facing stack for just that reason.

eBay

eBay’s story is a lot like Netflix’s. For a long time, just about everything in eBay’s tech stack was based on Java. A few years ago, eBay encountered a problem that Java wasn’t the right solution for. They decided to give NodeJS a shot instead.

Node worked so well that eBay not only kept using it for that particular service, they began migrating their entire user-facing stack to NodeJS. Now, just about everything that you interact with on eBay is powered by Node. Sure, beneath Node, Java is still dealing with their databases, but eBay still places a lot of trust in NodeJS.

LinkedIn

LinkedIn relies on NodeJS for its mobile site. A few years back, LinkedIn used Rails for its mobile site. As with other large Rails applications, it was slow, monolithic, and it scaled poorly.

LinkedIn switched over to NodeJS to solve its scaling problems. Node’s asynchronous capabilities allowed the LinkedIn mobile site to perform more quickly than before while using fewer resources. Node also made data sharing and building APIs easier for LinkedIn developers.

--

--