DEV Community

Cover image for Important Topics for Frontend Development Interview
Vamsi Krishna
Vamsi Krishna

Posted on

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();

// 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

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('');

Enter fullscreen mode Exit fullscreen mode

Top comments (1)

ikemkrueger profile image
Ikem Krueger • Edited

I think the post could be improved, by answering this questions:

What is Scoping?

What part of the code is in a block/function/global scope?

What is Hoisting?

Why does the code in your second example doesn't work?

What is a callback?

What part of the code shows exactly the callback?

What is async and await?

Under what conditions is the execution stopped/continued?