Javascript

Shuvo Goswami
4 min readMay 6, 2021

Call stack : JavaScript can do one single thing at a time because it has only one call stack. The call stack is a mechanism that helps the JavaScript interpreter to keep track of the functions that a script calls. Every time a script or function calls a function, it’s added to the top of the call stack. Every time the function exits, the interpreter removes it from the call stack .A function either exits through a return statement or by reaching the end of the scope.

Cross browser testing : Cross browser testing means to test website or a application in multiple browser. It can be done of an web and mobile application

Blocking : A blocking operation occurs when the execution of javascript operations is pulsed and must wait for a non-javascript operation to complete executing. By non-javascript operations, I mean operations like reading or writing data to a file, making a network request, reading or persisting data to a database e.t.c.Blocking operations occurs in node.js because Javascript in it’s most basic form is a synchronous, blocking, single-threaded language which can only perform several operations one at a time and since Node.js is a cross-platform JavaScript runtime environment, it runs its operations in a single process without creating a new thread for every request.

Try catch :

alert (“hi”);

alert (“x”);

alert(“bye everyone”);

this code will not work because X is not decleared .In program if we get a error in a line then the rest of the program will not work though it was right. Run of the program will stop.but if anyone use try catch function then the rest of the other program will work.

Try{ alert (“hi”);

alert (“x”);

alert(“bye everyone”);

}

catch {

alert (“problem “)

};

Comments : JavaScript comments can be used to explain JavaScript code, and to make it more readable. JavaScript comments can also be used to prevent execution, when testing alternative code.

Var Declarations and Hoisting : In JavaScript, a variable can be declared after it has been used.In other words; a variable can be used before it has been declared.

Block Binding in Loops : Traditionally, the way variable declarations work has been one tricky part of programming in JavaScript. In most C-based languages, variables (or bindings) are created at the spot where the declaration occurs. In JavaScript, however, this is not the case. Where your variables are actually created depends on how you declare them, and ECMAScript 6 offers options to make controlling scope easier. This chapter demonstrates why classic var declarations can be confusing, introduces block-level bindings in ECMAScript 6, and then offers some best practices for using them.

Global Block Bindings : Another way in which let and const are different from var is in their global scope behavior. When var is used in the global scope, it creates a new global variable, which is a property on the global object (window in browsers). That means you can accidentally overwrite an existing global using var, such as:

// in a browser

var RegExp = “Hello!”;

console.log(window.RegExp); // “Hello!”

var ncz = “Hi!”;

console.log(window.ncz); // “Hi!”

Even though the RegExp global is defined on window, it is not safe from being overwritten by a var declaration. This example declares a new global variable RegExp that overwrites the original. Similarly, ncz is defined as a global variable and immediately defined as a property on window. This is the way JavaScript has always worked.

If you instead use let or const in the global scope, a new binding is created in the global scope but no property is added to the global object. That also means you cannot overwrite a global variable using let or const, you can only shadow it. Here’s an example:

// in a browser

let RegExp = “Hello!”;

console.log(RegExp); // “Hello!”

console.log(window.RegExp === RegExp); // false

const ncz = “Hi!”;

console.log(ncz); // “Hi!”

console.log(“ncz” in window); // false

Here, a new let declaration for RegExp creates a binding that shadows the global RegExp. That means window.RegExp and RegExp are not the same, so there is no disruption to the global scope. Also, the const declaration for ncz creates a binding but does not create a property on the global object. This capability makes let and const a lot safer to use in the global scope when you don’t want to create properties on the global object.

spread operator: spread operator is a useful nad quick syntax for adding items to arrays, combining arrays or objects and spreading an array into function's arguments

Arrow functions: ES6 arrow functions provide you with an alternative way to write a shorter syntax compared to the function expression.

--

--