Important Topics for Frontend Development Interview

vamsitupakula_

Vamsi Krishna

Posted on July 19, 2022

Important Topics for Frontend Development Interview

Topics to master

There are some topics in JavaScript to master if you want to crack any frontend interview.

  1. Scoping
  2. Hoisting
  3. Closures
  4. Callbacks
  5. Promises
  6. Async and Await

What is Scoping ?

Scoping in JavaScript determines the accessibility of variables, objects and functions.
There are three types of scopes in JavaScript
a. Block Scope
b. Function Scope
c. Global Scope

Image description

variables declared with let and const have block scope but variables declared with var doesn't have any block scope.

Function scope is when you determine a variable inside a function then you cannot access.

What is Hoisting ?

Hoisting in javascript is a behavior in which a function or variable can be used before declaration.
Image description

In terms of variables, var is hoisted and let and const does not allow hoisting.
the following code will give you error.
Image description

What is Closure ?

Closure means that an inner function always has the access to outer function even after the outer function has returned.

const hello = () => {
    let greet = "hello & welcome";
    const welcome = () => console.log(greet);
    return welcome;
}

const fun = hello();
fun();

// hello & welcome
Enter fullscreen mode Exit fullscreen mode

What is a callback ?

A callback is a function which is passed as a parameter into another function which is going to be executed after completion of a task.

setTimeout(() => {
    console.log("hello, inside boy");
}, 2000);

console.log("hello outside boy");

// hello outside boy
// hello, inside boy
Enter fullscreen mode Exit fullscreen mode

What are promises ?

A JS promise is similar to real life promise will make it happen or we don’t

JS promise has three states :

  • Pending
  • Resolved
  • Rejected

https://www.freecodecamp.org/news/content/images/2020/06/Ekran-Resmi-2020-06-06-12.21.27.png

What is async and await

Stop and wait until something is resolved. We use the async keyword with a function to represent that the function is an asynchronous function.

async function returns a promise.

const fetchAPI = async () => {
    const res = await fetch('https://api.quotable.io/random');
    console.log(res);
}

fetchAPI();
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
vamsitupakula_
Vamsi Krishna

Posted on July 19, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related