Junior JavaScript Developer Interview Flashcards
1. What are the different data types in JavaScript?
Number, String, Boolean, Null, Undefined, Object, Symbol, BigInt.
2. What is the difference between var
, let
,
and const
?
-
var
: function-scoped, can be redeclared and updated.
-
let
: block-scoped, can be updated but not redeclared in
the same scope.
-
const
: block-scoped, cannot be updated or redeclared.
3. What is a closure in JavaScript?
A closure is a function that remembers and accesses variables from its
outer scope even after that outer function has finished executing.
4. What are arrow functions, and how are they different from regular
functions?
Arrow functions have a shorter syntax and do not have their own
this
, arguments
, or super
. They
inherit this
from their surrounding context.
5. Explain event bubbling.
Event bubbling is the process where an event starts from the deepest
target element and then propagates up to its ancestors in the DOM tree.
6. How do you create an object in JavaScript?
- Using object literal:
{ key: value }
- Using constructor:
new Object()
- Using
Object.create()
method.
7. What is the difference between ==
and ===
?
==
compares values with type coercion.
-
===
compares values without type coercion (strict
equality).
8. What is hoisting?
Hoisting is JavaScript's behavior of moving declarations
(var
, function
) to the top of their scope
before code execution.
9. How does the this
keyword work?
this
refers to the object that is executing the current
function. It varies based on how the function is called.
10. What are promises in JavaScript?
Promises represent the eventual completion (or failure) of an
asynchronous operation and its resulting value.
11. What is the difference between synchronous and asynchronous code?
-
Synchronous code runs sequentially, blocking the thread until
finished.
-
Asynchronous code runs independently, allowing other code to run
while waiting.
12. What is the DOM?
The Document Object Model (DOM) is a programming interface for HTML and
XML documents, representing the page so scripts can change the document
structure, style, and content.
13. How do you handle errors in JavaScript?
Using try...catch
blocks, and optionally
finally
to run code regardless of error.
14. What is the difference between null
and
undefined
?
null
is an assigned value meaning "no value".
-
undefined
means a variable has been declared but not
assigned a value.
15. What is the purpose of the map()
method?
map()
creates a new array by applying a function to each
element of the original array.