Each question below shows the correct answer with a full explanation. Use these to build conceptual understanding before attempting a timed quiz.
JavaScript FundamentalsEasy
Q1. Which keyword declares a variable in JavaScript?
- A.variable
- B.var✓ Correct
- C.declare
- D.let
Explanation
The var keyword declares a variable in JavaScript.
Report an error in this question
JavaScript FundamentalsEasy
Q2. What is the correct way to write a single-line comment in JavaScript?
- A.<!-- comment -->
- B./* comment */
- C.// comment✓ Correct
- D.# comment
Explanation
Single-line comments start with //.
Report an error in this question
JavaScript FundamentalsEasy
Q3. Which operator is used for strict equality in JavaScript?
- A.===✓ Correct
- B.==
- C.=
- D.!=
Explanation
=== checks both value and type equality.
Report an error in this question
JavaScript FundamentalsEasy
Q4. What does console.log() do?
- A.Creates a modal dialog box on screen
- B.Outputs a message to the browser console✓ Correct
- C.Logs the user into a website account
- D.Creates a new log file on disk
Explanation
console.log() outputs values to the browser console for debugging.
Report an error in this question
JavaScript FundamentalsEasy
Q5. Which data type represents true or false?
- A.Number
- B.Undefined
- C.String
- D.Boolean✓ Correct
Explanation
Boolean has only two values: true and false.
Report an error in this question
JavaScript FundamentalsEasy
Q6. How do you create a function in JavaScript?
- A.create myFunc() {}
- B.def myFunc() {}
- C.func myFunc() {}
- D.function myFunc() {}✓ Correct
Explanation
Functions are declared using the function keyword.
Report an error in this question
JavaScript FundamentalsEasy
Q7. What is an array in JavaScript?
- A.An ordered collection of values✓ Correct
- B.A type of reusable function
- C.A single primitive value in memory
- D.A CSS property declaration
Explanation
An array is an ordered collection of values accessed by numeric indices.
Report an error in this question
JavaScript FundamentalsEasy
Q8. How do you write an if statement in JavaScript?
- A.if (x > 5) {}✓ Correct
- B.if x > 5 {}
- C.when (x > 5) {}
- D.if x > 5 then
Explanation
JavaScript if statements use parentheses for the condition and curly braces for the code block.
Report an error in this question
JavaScript FundamentalsEasy
Q9. Which method adds an element to the end of an array?
- A.add()
- B.insert()
- C.append()
- D.push()✓ Correct
Explanation
push() adds one or more elements to the end of an array.
Report an error in this question
JavaScript FundamentalsEasy
Q10. What does the typeof operator return?
- A.The CSS type selector for an HTML element
- B.A string indicating the data type of a value✓ Correct
- C.The file type extension of a source file
- D.The element type in an HTML document
Explanation
typeof returns a string indicating the type of the operand.
Report an error in this question
JavaScript FundamentalsMedium
Q11. What is the difference between let and var?
- A.var has block scope; let has function scope
- B.let has block scope; var has function scope✓ Correct
- C.They are identical in scoping behavior
- D.let is significantly slower in performance
Explanation
let is block-scoped, while var is function-scoped.
Report an error in this question
JavaScript FundamentalsMedium
Q12. What is a closure in JavaScript?
- A.A type of loop for iterating over arrays
- B.A built-in method to end a running program
- C.A method for closing the browser window
- D.A function accessing its outer scope variables✓ Correct
Explanation
A closure is a function that retains access to its lexical scope's variables.
Report an error in this question
JavaScript FundamentalsMedium
Q13. What is the purpose of the 'this' keyword?
- A.Refers to the previously declared variable value
- B.Refers to the current CSS style being applied
- C.Refers to the object executing current function✓ Correct
- D.Creates a new object instance in current scope
Explanation
'this' refers to the object context in which the current function is executing.
Report an error in this question
JavaScript FundamentalsMedium
Q14. What is hoisting in JavaScript?
- A.Moving declarations to the top of their scope✓ Correct
- B.Uploading files from the client to the server
- C.Raising and throwing runtime error exceptions
- D.Lifting DOM elements higher in the page layout
Explanation
Hoisting moves declarations to the top of their scope before execution.
Report an error in this question
JavaScript FundamentalsMedium
Q15. What is the difference between null and undefined?
- A.undefined always indicates a runtime error occurred
- B.They are identical in meaning and behavior
- C.null is intentional absence; undefined means not assigned✓ Correct
- D.null is for numbers; undefined is for string values
Explanation
null is explicitly assigned to indicate no value, while undefined means not yet assigned.
Report an error in this question
JavaScript FundamentalsMedium
Q16. What does the map() method do on an array?
- A.Creates a geographic map data visualization
- B.Sorts the array elements in ascending order
- C.Creates a new array by applying a function to each item✓ Correct
- D.Maps array indices to their corresponding values
Explanation
map() creates a new array by calling a function on every element.
Report an error in this question
JavaScript FundamentalsMedium
Q17. What is event bubbling in JavaScript?
- A.A CSS animation effect using keyframe transitions
- B.A memory leak issue caused by circular references
- C.Creating animated bubble visual effects on screen
- D.When an event on a child propagates up through parents✓ Correct
Explanation
Event bubbling means an event propagates from the target element up through its ancestors.
Report an error in this question
JavaScript FundamentalsMedium
Q18. What is the purpose of JSON.parse()?
- A.Compresses JSON data to reduce its file size
- B.Creates a new JSON file on the server disk
- C.Converts a JSON string into a JavaScript object✓ Correct
- D.Validates JSON syntax for correctness and errors
Explanation
JSON.parse() transforms a JSON string into a JavaScript object.
Report an error in this question
JavaScript FundamentalsMedium
Q19. What is template literal syntax in JavaScript?
- A.Using single quotes around string literals
- B.Using double quotes around string values
- C.Using the + operator for concatenation
- D.Using backticks with ${} for interpolation✓ Correct
Explanation
Template literals use backticks and ${expression} syntax to embed expressions in strings.
Report an error in this question
JavaScript FundamentalsMedium
Q20. What is destructuring in JavaScript?
- A.Permanently deleting JavaScript objects from memory
- B.Unpacking values from arrays or objects into variables✓ Correct
- C.Breaking code into smaller modules and files
- D.Removing DOM elements from the document tree
Explanation
Destructuring extracts values from arrays or objects into separate variables.
Report an error in this question
JavaScript FundamentalsHard
Q21. What is the event loop in JavaScript?
- A.A mechanism handling async callbacks via call stack✓ Correct
- B.An event listener looping through all DOM elements
- C.A standard for loop iterating over event arrays
- D.A DOM traversal method for walking element tree
Explanation
The event loop checks the call stack and pushes callbacks from the task queue.
Report an error in this question
JavaScript FundamentalsHard
Q22. What is the difference between == and === in terms of type coercion?
- A.Both operators perform type coercion
- B.Neither operator performs type coercion
- C.== performs type coercion; === does not✓ Correct
- D.=== performs type coercion; == does not
Explanation
== converts operands to the same type before comparing, while === requires both type and value to match.
Report an error in this question
JavaScript FundamentalsHard
Q23. What is the Temporal Dead Zone (TDZ)?
- A.A time-related API for scheduling delayed operations
- B.A concept related to memory management and GC
- C.A garbage collection phase reclaiming unused memory
- D.The period between scope entry and let/const declaration✓ Correct
Explanation
The TDZ is the period from the start of a block until the let/const declaration is reached.
Report an error in this question
JavaScript FundamentalsHard
Q24. What is the difference between call(), apply(), and bind()?
- A.Only bind invokes the function immediately when called
- B.call and apply invoke immediately; bind returns a new function✓ Correct
- C.They are all identical in functionality
- D.call is for arrays; apply is for objects arguments
Explanation
call() takes individual arguments, apply() takes an array, and bind() returns a new function.
Report an error in this question
JavaScript FundamentalsHard
Q25. What is a WeakMap in JavaScript?
- A.A collection with weakly referenced object keys for GC✓ Correct
- B.A smaller and more limited version of Map class
- C.A map collection with weak security encryption
- D.A map storing only string keys and string values
Explanation
WeakMap holds weak references to object keys, allowing garbage collection.
Report an error in this question
JavaScript FundamentalsHard
Q26. What is the prototype chain in JavaScript?
- A.A CSS inheritance model for cascading styles
- B.The mechanism objects use to inherit properties✓ Correct
- C.A linked list data structure for sequential data
- D.A blockchain implementation for distributed apps
Explanation
The prototype chain links objects together for property lookup inheritance.
Report an error in this question
JavaScript FundamentalsHard
Q27. What is tail call optimization in JavaScript?
- A.A DOM rendering optimization for reducing paint operations
- B.A CSS optimization technique for faster style calculations
- C.Optimizing the last element of an array for access
- D.Reusing the stack frame for a function call in tail position✓ Correct
Explanation
Tail call optimization reuses the current stack frame for function calls in tail position.
Report an error in this question
JavaScript FundamentalsHard
Q28. What is the difference between Object.freeze() and Object.seal()?
- A.freeze prevents all changes; seal allows modifying values✓ Correct
- B.freeze only prevents deletion of properties
- C.seal prevents all changes including modifications
- D.They are identical in behavior on objects
Explanation
Object.freeze() makes an object fully immutable, while Object.seal() prevents adding/removing but allows modification.
Report an error in this question
JavaScript FundamentalsHard
Q29. What is a Symbol in JavaScript?
- A.A unique immutable primitive for property identifiers✓ Correct
- B.A string formatting token for template processing
- C.A CSS icon or symbol for decorative elements
- D.A mathematical operator for advanced calculations
Explanation
Symbol creates a unique, immutable primitive value for non-colliding property keys.
Report an error in this question
JavaScript FundamentalsHard
Q30. What is the purpose of generator functions?
- A.To generate HTML markup from template files
- B.To create iterators that pause and resume via yield✓ Correct
- C.To create class instances from constructor functions
- D.To generate random numbers for cryptographic use
Explanation
Generator functions (function*) produce iterators that can pause with yield and resume later.
Report an error in this question