arrow_back Back to Curriculum
javascript

JavaScript & ES6+

In-depth Javascript mechanics focusing on asynchronous handling, closures, ES6+ syntax, and frontend logic often queried in local full-stack interviews.

Interview Questions

25 Total
Q1.

What is Hoisting in JavaScript?

Medium

Hoisting is JavaScript's default behavior of moving declarations to the top of the current scope. Variables defined with `let` and `const` are hoisted to the top of the block, but not initialized (temporal dead zone).

Q2.

Explain Closures with an example.

Medium

A closure is a function having access to the parent scope, even after the parent function has closed. Often used to create private variables.

Q3.

What is the Event Loop?

Hard

The event loop is a mechanism that allows JavaScript to perform non-blocking operations by offloading operations to the system kernel (Web APIs) whenever possible, orchestrating the Call Stack and the Callback Queue.

Q4.

Difference between `==` and `===`?

Easy

`==` checks for value equality with type coercion, whereas `===` checks for strict equality (both value and type must be the same).

Q5.

What is the difference between var, let, and const in JavaScript?

Easy

Var is function scoped, let and const are block scoped. Let and const are used for declarations that should not be reassigned or redeclared, while var allows for redeclaration.

Q6.

What is the purpose of the 'use strict' directive in JavaScript?

Easy

The 'use strict' directive is used to enable strict mode in JavaScript, which helps catch common coding mistakes and 'unsafe' actions.

Q7.

How do you create a Promise in JavaScript?

Medium

A Promise is created using the Promise constructor and passing a callback function that takes two arguments: resolve and reject.

Q8.

What is the difference between a Map and an Object in JavaScript?

Medium

A Map is a data structure that stores key-value pairs, similar to an Object. However, Maps allow for any type of key, not just strings and symbols, and preserve the order of insertion.

Q9.

What is the purpose of the 'finally' block in a try-catch statement?

Easy

The 'finally' block is used to execute code regardless of whether an exception was thrown or caught, and is typically used for cleanup or releasing resources.

Q10.

How do you use the 'for...of' loop in JavaScript?

Easy

The 'for...of' loop is used to iterate over iterable objects such as Arrays, Maps, and Sets, and assigns the value of each property to a variable on each iteration.

Q11.

What is the difference between 'null' and 'undefined' in JavaScript?

Easy

'null' represents the absence of a value, while 'undefined' represents an uninitialized variable or a property that does not exist.

Q12.

How do you use the 'Set' data structure in JavaScript?

Easy

A Set is a collection of unique values, and can be created using the Set constructor and adding values using the 'add' method.

Q13.

What is the purpose of the 'Object.freeze' method?

Medium

The 'Object.freeze' method is used to freeze an object, making it immutable and preventing any changes to its properties.

Q14.

How do you use the 'Array.prototype.find' method?

Easy

The 'Array.prototype.find' method is used to find the first element in an array that satisfies a provided testing function.

Q15.

What is the difference between '=='' and '===' in JavaScript?

Easy

'==' checks for loose equality, while '===' checks for strict equality, also known as identity.

Q16.

How do you use the 'Array.prototype.reduce' method?

Medium

The 'Array.prototype.reduce' method is used to apply a function to each element in an array and reduce it to a single value.

Q17.

What is the purpose of the 'Symbol' data type in JavaScript?

Medium

The 'Symbol' data type is used to create unique and immutable values that can be used as property keys in objects.

Q18.

How do you use the 'async/await' syntax in JavaScript?

Medium

The 'async/await' syntax is used to write asynchronous code that is easier to read and maintain, by using the 'async' keyword to declare a function that returns a Promise, and the 'await' keyword to pause execution until a Promise is resolved.

Q19.

What is the difference between 'console.log' and 'console.debug'?

Easy

'console.log' is used to output a message to the console, while 'console.debug' is used to output a debug message to the console, which can be filtered out.

Q20.

How do you use the 'Proxy' object in JavaScript?

Hard

A Proxy object is used to create a virtualized representation of an object, and can be used to intercept and modify the behavior of an object.

Q21.

What is the purpose of the 'Reflect' object in JavaScript?

Hard

The 'Reflect' object is used to provide a way to intercept and modify the behavior of an object, and provides methods for common operations such as getting and setting properties.

Q22.

How do you use the 'Atomics' object in JavaScript?

Hard

The 'Atomics' object is used to provide a way to perform atomic operations on SharedArrayBuffers, which can be used to share data between threads.

Q23.

What is the difference between 'setTimeout' and 'setInterval'?

Easy

'setTimeout' is used to execute a function after a specified delay, while 'setInterval' is used to execute a function repeatedly at a specified interval.

Q24.

How do you use the ' WeakMap' data structure in JavaScript?

Medium

A WeakMap is a data structure that stores key-value pairs, where the keys are weakly referenced, meaning they can be garbage collected if no other references to the key exist.

Q25.

What is the purpose of the ' Intl' object in JavaScript?

Medium

The 'Intl' object is used to provide a way to perform internationalization and formatting of data, such as dates, numbers, and currencies.