50+ Javascript Interview Questions – Dev Community

Level: Beginner to Intermediate
Subject:

work basics
job announcements
function scope
function arguments
function expression
arrow work
Higher order function and callback
close
IIFE
worldwide Act

Does JavaScript allow function overloading?

What does it mean, “In JavaScript, functions are first-class citizens”?

What are the different ways to define a function?

Can a function name be used as a normal variable?

What is the difference between “myFunction” and “myFunction()”?

Does every function in JavaScript return something, even if not explicitly called? If so, what does it return by default?

Can a function return multiple values? What tricks can you use?

job announcements

What are function declarations or function statements?

Are function declarations always hoisted?

Can a function be declared inside another function?

function scope

What is function scope or local scope?

How does hoisting work inside a function body?

Between var, let, and const, which allows hoisting?

What is block scope and how is it different from function scope?

function arguments

What is the difference between a function parameter and a function argument?

What is the “argument” context inside the function body? What purpose does it serve?

Is “arguments” an array? Explain its behaviour.

What is a “variadic function”?

What are the different ways to access a variable number of arguments passed to a function inside its body?

What is the Rest Parameter Operator? How does this work inside a function’s parameter list?

Define some valid and invalid use cases of the rest parameter.

Define the key difference between “argument” and “a comfort parameter”.

function expression

What is Function Expression?

How is a function expression different from a function declaration?

Are function expressions hoisted?

What is a Named Function Expression?

What is an anonymous function expression?

Give some example use cases for using function expressions instead of function statements.

arrow work

What is Arrow Function?

Which ECMAScript version introduced the arrow function?

Given a normal function, convert it to an arrow function.

When is it not mandatory to include arguments inside ( and ) in arrow functions?

When does an arrow function return implicitly even if no return keyword is specified?

What are some of the major differences between normal and arrow functions?

Higher order function and callback

What is a callback function?

Highlight some use cases for callback functions.

Mention some in-built functions that accept callbacks.

What is a higher-order function (HOF)?

close

Define closure.
When does JavaScript create closures?
What is Lexical Scope?
Define different areas within a closure.
Why do you think closure is useful?
Throw light on some disadvantages of closure.

IIFE

What is IIFE?

Highlight some use cases of IIFE.

Why do we see less use of IIFE nowadays? What are its options?

worldwide Act

Which function should we use to delay the execution of a code?

What is setTimeout()? Define what parameters it accepts.

Will setTimeout(code, 0) execute the code immediately?

How to cancel scheduled execution?

Which function should we use to execute a piece of code repeatedly at some time interval?

What is setInterval()? Define what parameters it accepts.

How to prevent timed and repetitive execution of code specified by setInterval()?

Leave a Comment