10 Important Topics Learn in JavaScript

What the heck is the event loop anyway:

We know that JavaScript is a combination of synchronous events and asynchronous events. Synchronous is like one after another work and asynchronous are things like callback and promises.

1.Synchronous: javaScript is single-threaded which means always only one thread that does all of the work that needs to happen in a javascript runtime, It also exceptions to that like worker threads and native stuff but its application execution is just one thread. So if we load a page in a browser and that page executes a few javaScript functions there is one javaScript thread that’s executing it all. Let's have a real-life example A hotel have only one waiter who served all the table of customers so here is a work rule first come first serve so which one table order first which serve first then after completed second table served. So event queue which holds the request of browser page so if you clicked calculate something and then click something print and that time event queue hold the request first done the calculate after go for the second print something. And this is the process event queue go until empty that is how to work with the synchronous event loop.

2.Asynchronous: Asynchronous are things like callback and promises. It also processes like a first in first out manner. Let's have some real-life example like the previous waiter example the waiter takes the order from table one synchronously and the waiter hands the order to the chief with a call back to say chief when the finished the ordered dish needs to be served to that table which first order. But here is the important thing waiter doesn't wait to finish the order he moves to take the other order to another table this process going on the manner and that is how to work asynchronous event loop.

JavaScript Data Types:

3.Primitive values are numbers and strings, among other things. Primitive values are always there when we need them.Primitive values are: undefined ,Null,Booleans,Numbers Strings Symbols,BigInts.

Object and Functions are also values, but they are not primitive its special because they can manipulate code. It can connect to other values.

Expression is if we want to know whether it's better to confess our true feelings to our best friend to keep waiting until we both turn into skeletons, javascript won't is of much help If we ask the expression 3+3, javaScript will answer with value 6.

Check Type: To check the type of a value then also depend on the type of operator here are some different type string values such as number, string, or object.

Error Handling:

4.This is not a matter we are a great programmer, sometimes our scripts have errors. Thet may occur because of our mistakes, unexpected user input, an erroneous server response, and for a thousand other reasons. So catch the error and solve it as passion/

In this picture show the diagram of catching error:

  1. First the code in try {...} is executed
  2. If there were no errors, then catch (err) is ignored: the execution reaches the end of try and goes on, skipping catch.
  3. If an error occurs, then the try execution is stopped, and control flows to the beginning of catch (err). The err variable (we can use any name for it) will contain an error object with details about what happened.

So, an error inside the try {...} block does not kill the script – we have a chance to handle it in catch.

It is the process of error handling.

Coding Style in JavaScript: Click to Know the details

5.Coding style: Curly Braces which is in mos javaScript projects curly braces are written in “Egyptian” style. Line Length is a long horizontal line of code, Its best practice to split them. There are two types of indents one is Horixontal indent:2 or 4 spaces and another is Vertical indents:empty lines for splitting code into logical blocks and also Semiclolon,Nesting Levels,Function Placement etc most important for Coding style in javaScript.

6.Comments can be single-line: starting with // and multiline: /* ... */.We normally use them to describe how and why the code works. At first, sight, commenting might be obvious, but novices in programming often use them wrongly. It's most useable when the code is not clear if the code will understand without comment then it's called a bad comment. An important sign of a good developer is using comments to understand the code because good comments allow us to maintain the code well, come back to it after a delay and use it more effectively.

Balancing Client And Server Caching in Web Application Development

7.Caching is In computing, a cache is a high-speed data storage layer that stores a subset of data, typically transient in nature so that future requests for that data are served up faster than is possible by accessing the data’s primary storage location. Caching allows you to efficiently reuse previously retrieved or computed data.

Cost data means factual information concerning details; including expected monetary values for overhead, and other pricing components which the contractor has included, or will include as part of performing the contract. we cannot assume the client is capable of handling that cost.

Client caches help limit the data cost incurred by the user by keeping commonly referenced data locally. The client often requests data that may not be large but is indeed continuously needed.

8.Server caching helps limit the cost incurred by the server and its underlying systems. Many requests made by clients can either be responded to using the same data or responded to using parts of the same requests made by others.

The API request is:

  1. The client requests the API.
  2. This request is received by the server.
  3. The server checks for a local copy of the file requested. While this check has a cost, the cost is still extremely low compared to the actual cost of computing a massive database check or generating content.
  4. If the local resource exists, the server responds with its resource URI.
  5. The client grabs the cached content.
  6. If the local resource does not exist, the request is processed normally.

9.Hybrid Caching isn’t just a choice between one or the other, either — you can combine client and server caching to have a more complete solution if your specific system allows it. In this approach, you leverage both types of caching to free up the data cost burden on both sides of the equation by asking whoever is responding or requesting to first make a local query.

From the API perspective, the flow would follow as such:

  1. A client makes a request
  2. It first checks for a local copy. If the copy doesn’t exist, it contacts the server with a request for this content.
  3. On the server-side, the server will then check for its own local copy,
  4. If a copy exists, it will serve it. Or, it will generate a new one if the copy does not exist.

Introduction to cross-browser testing

10.Different browsers other than the one or two that you use regularly on your devices, including slightly older browsers that some people might still be using, which don’t support all the latest, shiniest CSS and JavaScript features.

It occurs because sometimes browsers have bugs, or implement features differently. This situation is a lot less bad than it used to be; back when IE4 and Netscape 4 were competing to be the dominant browser in the 1990s, browser companies deliberately implemented things differently to each other to try to gain competitive advantage, which made life hell for developers. Browsers are much better at following standards these days, but differences and bugs still creep through sometimes.

And steps two tests this initial planning, development Testing, Fixed

11.Block Bindings: Variables are created at the spot where the declaration occurs. In JavaScript, however, this is not the case where variables are actually created depends on how we declared them. Variable declarations using var are treated as if they are at the top of the function (or global scope).Block-level declaration inaccessible outside of given block scope. And it created inside a function .the identifier in a let declaration inside that scope causes an error to be thrown. Variables declared using const are considered constants, meaning their values cannot be changed once set. For this reason, every const variable must be initialized on the declaration

Web Developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store