Most applications work because of an interaction between a client (user’s device) and a remote server. The client makes requests for data from the server. The server receives the request, processes it and then responds accordingly. The response sent back is in a user readable format and is thus acceptable by the client. But this process takes time as well as resources. Although we usually need this connection, in some projects, Js often helps to avoid it.
Autocomplete: The search box gives suggestions, based on what the user has already typed in.
Fixes layout issues to avoid the overlapping of elements on the web page.
Adds animation to the page to make it more attractive for users.
JS is single-threaded. This means that the instructions execute sequentially, one at a time. This is possible with the help of the following components:
The engine consists of 2 components:
Memory Heap– Memory allocation takes place in this.
Call Stack– When the script calls a function, the interpreter first adds it to the call stack and then starts executing it.
The JS Engine works inside an environment for more features used at runtime. Although js is single-threaded, the runtime environment consists of a thread pool. It allows js to simultaneously run in the background while the user browses without interrupting the program flow.
Js Event Loop
This mechanism manages all the threads from the thread to pool in the order of their execution i.e. it handles the callbacks. A callback is a piece of code executed when a particular event i.e. when a mouse click occurs.
If the event occurs, the environment puts the callback in the Event Handler under the Event Loop. Callbacks code always executed one at a time.
Features of JS
it supports object-oriented programming concepts.
It is a platform-independent and case- sensitive.
it Provides various in-built functions like alert(), prompt() etc.
Capable of exception handling.
it allows the use of functions with or without any name. the function without name is called an anonymous function.
Ease of Learning
Decreases the Server Load
We avoid server traffic by validating user input on the client side form. It reduces server load, giving its advantage over other web languages.
Js Richin Interfaces
it provides numerous interfaces to make the webpage more interactive.
Different Browser Interpretations
Js Security Issues
Js only supports single inheritance and not multiple inheritances.
Sluggish Bitwise Operation
Js uses 32-bit bitwise operands but 64-bit floating-point numbers. Thus before performing any operation, Js converts the number to 32-bits signed integers. After the operation, it converts them back to 64-bits Jsnumbers. This reduces the speed taken by the script.