Swapna Kumar Panda's profile picture
Swapna Kumar Panda
@swapnakpanda
View on Twitter

50+ JavaScript Interview Questions

Level: Beginner to Intermediate Topics:

➊ Functions Basics

➋ Function Declarations

➌ Function Scope

➍ Function Arguments

➎ Function Expressions

➏ IIFE

➐ Arrow Functions

➑ Higher Order Function & Callbacks

➒ Closure

➓ Global Functions

➊ Functions Basics

➀ Does JavaScript allow function overloading?

➁ What does it mean, "In JavaScript, functions are first-class citizens"?

➂ What are different ways of defining a function?

➃ Can a function name be used as a normal variable?

➄ What is the difference between "myFunction" and "myFunction()"?

➅ Does every function in JS return something even if not explicitly stated? If yes, what does it return by default?

➆ Can a function return multiple values? What trick can you apply?

➋ Function Declarations

➀ What are function declarations or, function statements?

➁ Are function declarations always hoisted?

➂ Can a function be declared inside another function?

➌ Function Scope

➀ What is a function scope or, local scope?

➁ How does hoisting work inside a function body?

➂ Among 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 function parameters and function arguments?

➁ What is "arguments" reference inside a function body? What purpose does it solve?

➂ Is "arguments" an array? Explain its behaviour.

➃ What is a "Variadic Function"?

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

➅ What is a rest parameter operator? How does it work inside the function's parameters list?

➆ Define some valid and invalid use cases of the rest parameter?

➇ Define significant differences between "arguments" and "a rest parameter".

➎ Function Expressions

➀ What is a 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 unnamed function expression?

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

➏ IIFE

➀ What is IIFE?

➁ Highlight some use cases of IIFE.

➂ Why do we see less usage of IIFE these days? What are its alternatives?

➐ Arrow Functions

➀ What is an arrow function?

➁ Which ES version introduced the arrow function?

➂ Given a normal function, convert it into an arrow function.

➃ When is it not mandatory to include arguments inside ( and ) in an arrow function?

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

➅ What are some key differences between a normal and an arrow function?

➑ Higher Order Function & Callbacks

➀ What is a callback function?

➁ Highlight some use cases for callback functions?

➂ Mention a few in-built functions that accept a callback.

➃ What is a higher-order function (HOF)?

➒ Closure

➀ Define closure.

➁ When does JavaScript create a closure?

➂ What is a lexical scope?

➃ Define various scopes within a closure.

➄ Why do you think closure is useful?

➅ Highlight a few disadvantages of closures.

➓ Global Functions

➀ Which function should we use to delay the execution of some piece of code?

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

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

➃ How to cancel the scheduled execution?

➄ Which function should we use to execute some piece of code repetitively at some time interval?

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

➆ How to stop the timed and, repetitive execution of code specified by setInterval()?

🚥 Disclaimer

⬘ Few questions covered here are mostly conceptual

⬗ I never claim only these types of questions are/should be asked during interviews

⬙ For interviews, you should have fundamentals strong. And you should be able to provide solutions to practical problems.

Hey 👋

I am a Tech Educator and, Mentor from India 🇮🇳

I am sharing Tutorials, Tips, Infographics, Cheat Sheets, Practice Questions, Project Ideas, and Roadmaps on Web Development, DSA and, Databases.

To never miss anything, Follow Me ✅

Help us raise more money for charities by sharing this content ♥️
Wait! Before you go...
Grab Exclusive Deals for Books, Courses, Software.
100% of Profits Are Donated To Research-Backed Charities.