DEV Community

Tanjir Ahmed
Tanjir Ahmed

Posted on

Things one needs to know as a javascript developer

Scopes
Scopes are basically the address of a variable where it is allocated. javascript always stays on root scope. In other words, Scopes are the boundaries for objects, functions and variables.
There are two types of scops available.
Local Scope: Local scope indicates the variables that are declared inside of a function and can not be accessed from outside.
Global scope: Global scopes are not like local scopes. Global scopes are declared out of function to be accessible from anywhere in the document.

  1. Immediately Invoked Function Expression(IIFE) IIFE goes just as its name indicates it is a function that immediately invokes execution As soon as it is declared The syntax for IIFE is (function () { statements })(); Hoisting Hoisting is basically a way to call a function before it is declared. In javascript through the context of hoisting all the declaration goes to the top of the program. Hoisting is a complicated topic in javascript. Most developer gets unexpected results. As for calling a function before initialization should be an error. But in javascript, we can do that for the concept of hoisting. Closures The closure is a function that is called inside of another function. The closure is used to get the local variable of another function. Callbacks Call back functions are the function that takes a function as an argument and returns another function. In the callback method, a function waits for another function to be called. function greeting(name) { alert('Hello ' + name); }

function processUserInput(callback) {
var name = prompt('Please enter your name.');
callback(name);
}

processUserInput(greeting);
Async Await
Async await is from es-7.
Async await is a concept of waiting for something to be complete. Async await is kind of similar to promises but it also creates asynchronous operations synchronously
In javascript, async-await is defined by 3 version
Call back. (ES5)
Promises. (ES6)
Async await (ES7)
The syntax for async-await is ;
Function async (){

Const post= await fetch(“URL”)
Await console.log (post)
}.

Top comments (0)