Control flow defines the order in which statements and expressions execute within a JavaScript program. At the heart of decision-making in JS are conditional statements: if, else if, and else blocks. These constructs evaluate boolean expressions or values implicitly coerced to booleans (truthy vs. falsy) to direct execution paths dynamically. Modern JavaScript development relies on mastering not only standard block-based branching but also shorthand alternatives like ternary expressions (? :) and short-circuit evaluation via logical operators (&&, ||). Understanding block scoping (let/const vs. var inside conditional blocks) and type coercion during evaluation is essential for writing error-free asynchronous and synchronous code
JavaScript Control Flow MCQs
1 min read
Correct Answer: b) Not Equal
Explanation:
In JavaScript, objects and arrays are compared by reference, not by value. Since 'a' and 'b' reference different memory addresses, a == b evaluates to false.
Correct Answer: a) 15
Explanation:
eval() executes string code in the local environment context, evaluating the expression 'x + 5' (10 + 5) to 15.
Correct Answer: a) 7
Explanation:
When i=0, j runs 3 times (count=3). When i=1, j=0 increments count (4); j=1 triggers continue outer, skipping j=1 and j=2. When i=2, j runs 3 times (count=7).
Correct Answer: a) true
Explanation:
new Boolean(false) constructs a wrapper object. All non-null objects in JavaScript evaluate to truthy when passed to Boolean().
Correct Answer: a) The returned value overrides the instance only if it is an object.
Explanation:
Constructors invoked with 'new' return the newly created object unless an explicit object is returned. If a primitive is returned, it is ignored.
Correct Answer: a) 1
Explanation:
Logical AND (&&) has higher precedence than OR (||). 2 && 0 evaluates to 0. Then 1 || 0 evaluates to 1.
Correct Answer: b) 1 followed by undefined
Explanation:
The catch block parameter 'x' shadows the outer 'var x'. Assigning x inside catch updates the catch-scoped parameter, leaving the outer function-scoped 'var x' as undefined.
Correct Answer: a) number
Explanation:
The self-invoking function returns 1. typeof 1 yields the string "number".
Correct Answer: a) 7
Explanation:
The first condition (x > 0) is true, so x becomes 7. The remaining 'else if' block in the chain is skipped entirely.
Correct Answer: a) 3 3 3
Explanation:
Because 'var' is function-scoped, all callbacks reference the single global loop variable 'i', which equals 3 after loop completion.
Correct Answer: a) 0
Explanation:
The nullish coalescing operator (??) falls back to the right operand only if the left operand is null or undefined. 0 is neither.
Correct Answer: b) default
Explanation:
The logical OR operator (||) falls back to the right operand if the left operand is falsy. 0 is falsy, so "default" is returned.
Correct Answer: c) "false"
Explanation:
Any non-empty string, including "false", evaluates to a truthy value in JavaScript.
Correct Answer: a) true
Explanation:
![] converts to false. The comparison [] == false coerces both sides to numbers: [] becomes 0 and false becomes 0, so 0 == 0 is true.
Correct Answer: b) false
Explanation:
Strict equality checking compares type and value without coercion. [] is an object reference while ![] is boolean false.
Correct Answer: a) A
Explanation:
The switch expression evaluates to true. The first case (a > 5) evaluates to true, triggering case 'A' and breaking immediately.
Correct Answer: b) undefined
Explanation:
Automatic Semicolon Insertion (ASI) places a semicolon after 'return', causing the function to return undefined.
Correct Answer: a) 4
Explanation:
The condition skipping even numbers leaves odd numbers i=1 and i=3. The accumulated total is 1 + 3 = 4.
Correct Answer: b) B
Explanation:
mark >= 90 is false. Evaluation shifts to mark >= 70, which is true (75 >= 70), returning "B".
Correct Answer: b) The finally block executes, then the unhandled error propagates.
Explanation:
The finally block always runs before control leaves the try-catch structure, even if an exception is thrown inside catch.
Correct Answer: b) 20
Explanation:
The logical AND assignment operator (x &&= 20) evaluates the left operand. Since 10 is truthy, x is assigned 20.
Correct Answer: a) 0
Explanation:
Because x is 0 (falsy), logical AND assignment short-circuits and leaves x unchanged as 0.
Correct Answer: b) Missing
Explanation:
Optional chaining safely returns undefined for obj?.b?.c. The nullish coalescing operator converts undefined to "Missing".
Correct Answer: b) 5
Explanation:
Iterations: start x=1 -> x becomes 3 -> x becomes 5. At x=5, condition (5 < 5) is false, ending loop with x = 5.
Correct Answer: b) SyntaxError: Undefined label 'loop'
Explanation:
Using a labeled break or continue statement targeting an un-declared or out-of-scope label identifier throws a SyntaxError.
Correct Answer: d) NaN
Explanation:
When all operands in a logical OR chain are falsy, the expression evaluates to the last operand (NaN).
Correct Answer: d) [1]
Explanation:
When all operands in a logical AND chain are truthy, the expression evaluates to the final operand ([1]).
Correct Answer: b) 1
Explanation:
A do...while loop runs the body once before checking condition. i increments from 0 to 1, then (1 < 0) evaluates to false.
Correct Answer: d) There is no built-in way to stop a standard forEach loop prematurely.
Explanation:
The Array.prototype.forEach method cannot be short-circuited with break or continue. To break early, use a standard for loop or for...of.
Correct Answer: b) 2 3
Explanation:
Case "b" matches, printing 2. Because there is no break after case "b", execution falls through to case "c", printing 3 before breaking.
Correct Answer: a) catch
Explanation:
The 'catch' block contains error-handling statements executed if an error is thrown in the preceding try block.
Correct Answer: b) False
Explanation:
The expression (num = 0) performs assignment, assigning 0 to num and evaluating to 0. Since 0 is falsy, the else block runs.
Correct Answer: a) 1
Explanation:
'let' is block-scoped. The declaration inside the 'if' block is distinct from the outer variable 'x', which remains equal to 1.
Correct Answer: b) true
Explanation:
Non-empty string literals, including "0", evaluate to true when converted to a boolean.
Correct Answer: a) Valid
Explanation:
a > 5 is true (10 > 5). Due to short-circuiting in logical OR, the whole condition evaluates to true without checking b.
Correct Answer: a) 0 2
Explanation:
When i=0, 0 is printed. When i=1, i increments to 2 and continue skips log. When i=2, 2 is printed. Loop ends when i becomes 3.
Correct Answer: a) for await...of
Explanation:
The 'for await...of' construct iterates sequentially over asynchronous iterable objects using promises.
Correct Answer: a) true
Explanation:
10 > 5 evaluates to true. Then true > 0 coerces true to 1, evaluating 1 > 0 which is true.
Correct Answer: b) false
Explanation:
5 > 10 evaluates to false. Then false > 0 coerces false to 0, evaluating 0 > 0 which is false.
Correct Answer: a) 2
Explanation:
The string "JavaScript" contains two lowercase 'a' characters, incrementing count twice.
Correct Answer: b) The finally block executes, then the TypeError is thrown up the call stack.
Explanation:
The finally block always executes. Since there is no catch block to intercept the exception, it propagates up after finally completes.
Correct Answer: a) true
Explanation:
The 'in' operator checks whether a specified property exists within an object or its prototype chain, returning true.
Correct Answer: a) true
Explanation:
In an array, property keys are numeric indices. Index 1 exists in [10, 20, 30], so '1 in arr' returns true.
Correct Answer: b) false
Explanation:
The 'in' operator checks for property keys/indices, not values. Index 30 does not exist in an array of length 3.
Correct Answer: a) break
Explanation:
The 'break' statement terminates the switch block and prevents execution from falling through to subsequent cases.
Correct Answer: a) false
Explanation:
NaN is defined as one of the falsy values in JavaScript.
Correct Answer: b) Second
Explanation:
a=0 is falsy, so the first condition fails. The second condition (0 === 0) is true, outputting 'Second'.
Correct Answer: a) To write catch blocks without specifying an error parameter e.g., catch { }.
Explanation:
Optional catch binding lets developers omit the error variable parameter when error details are unused inside catch.
Correct Answer: a) 4
Explanation:
x++ evaluates to 1 (x becomes 2). Then ++x increments x to 3 and evaluates to 3. 1 + 3 = 4.
Correct Answer: a) true
Explanation:
20 >= 18 is true, returning the truthy expression true.
Correct Answer: b) Fallback
Explanation:
Empty string "" is falsy, so logical OR falls back to the right operand "Fallback".
Correct Answer: a) ""
Explanation:
Empty string "" is not null or undefined, so nullish coalescing returns "".
Correct Answer: b) 4
Explanation:
Outer loop runs 2 times; inner loop runs 2 times per outer iteration. Total executions = 2 * 2 = 4.
Correct Answer: b) Uncaught SyntaxError: Illegal break statement
Explanation:
Using 'break' outside an iteration statement, switch block, or labeled statement raises a SyntaxError.
Correct Answer: b) Uncaught SyntaxError: Illegal continue statement
Explanation:
The 'continue' statement can only be used within loop bodies. Using it elsewhere causes a SyntaxError.
Correct Answer: b) B
Explanation:
5 > 10 is false, executing the else block.
Correct Answer: b) B
Explanation:
The initial condition is false, skipping "A". The secondary condition is true, returning "B".
Correct Answer: c) C
Explanation:
Both conditions evaluate to false, resolving the nested ternary chain to "C".
Correct Answer: a) throw
Explanation:
The throw statement raises custom user-defined exceptions during code execution.
Correct Answer: a) 13
Explanation:
a becomes 1 in try, error jumps to catch (a += 4 -> 5), finally runs unconditionally (a += 8 -> 13).
Correct Answer: b) 6
Explanation:
The loop calculates 1 + 2 + 3 = 6.
Correct Answer: c) do...while
Explanation:
The do...while loop tests the condition expression after executing the loop body.
Correct Answer: b) undefined
Explanation:
Optional chaining (?.) evaluates to undefined without calling the method if the target object is null.
Correct Answer: a) TypeError
Explanation:
Invoking properties or methods directly on null using dot notation raises a TypeError.
Correct Answer: a) High
Explanation:
10 > 5 is true, returning "High".
Correct Answer: a) true
Explanation:
Functions are reference object types in JavaScript and always convert to truthy values.
Correct Answer: a) true
Explanation:
Symbols are primitive values that always evaluate to truthy.
Correct Answer: b) false
Explanation:
0 is falsy. !0 is true, and !!0 converts it back to boolean false.
Correct Answer: a) true
Explanation:
1 is truthy. Double negation (!!) explicitly converts truthy values to boolean true.
Correct Answer: b) default
Explanation:
undefined is falsy, so logical OR evaluates and returns the right-hand value "default".
Correct Answer: b) default
Explanation:
null is falsy, so logical OR returns "default".
Correct Answer: b) default
Explanation:
false is falsy, causing logical OR to return "default".
Correct Answer: a) Loose
Explanation:
Loose equality (==) coerces string "5" to number 5, evaluating 5 == 5 as true.
Correct Answer: b) Mismatch
Explanation:
Strict equality (===) compares type and value without coercion. Number 5 does not equal string "5".
Correct Answer: b) Skips the rest of the current iteration block and moves to the next pass.
Explanation:
The continue keyword halts statement execution within the current loop iteration and advances execution flow.
Correct Answer: a) 0 1 2
Explanation:
The loop prints values 0, 1, and 2. When x reaches 3, condition (3 < 3) fails and loop terminates.
Correct Answer: c) ??=
Explanation:
The nullish assignment operator (??=) evaluates its left operand and performs assignment only if it is null or undefined.
Correct Answer: b) 50
Explanation:
Because x is null, the nullish assignment operator assigns 50 to x.
Correct Answer: a) 100
Explanation:
Because x is 100 (not nullish), the nullish assignment operator does not execute, leaving x as 100.
Correct Answer: a) Execution falls through to the next case.
Explanation:
Without a break statement, execution continues into the subsequent case block regardless of condition checks.
Correct Answer: b) Cat
Explanation:
Since "Dog" is non-empty and truthy, logical AND evaluates and returns the second operand "Cat".
Correct Answer: a) Dog
Explanation:
Logical OR short-circuits on the first truthy operand encountered and returns "Dog".
Correct Answer: c) X followed by Y
Explanation:
Without curly braces {}, only `console.log("X")` is conditional. `console.log("Y")` runs unconditionally.
Correct Answer: b) Y
Explanation:
Without braces, `console.log("X")` is skipped because (2 > 5) is false. `console.log("Y")` executes unconditionally.
Correct Answer: b) ReferenceError
Explanation:
Accessing an identifier that has not been declared anywhere throws a ReferenceError.
Correct Answer: a) 10
Explanation:
The 'with' statement extends scope chain to search properties of the provided object ('a' resolves to obj.a = 10).
Correct Answer: b) It makes code scope ambiguous, slow to optimize, and is forbidden in strict mode.
Explanation:
The 'with' statement introduces scope ambiguity, impairs performance optimization, and throws a SyntaxError in strict mode.
Correct Answer: d) Hit
Explanation:
Logical OR checks left-to-right and returns the first truthy operand, which is string "Hit".
Correct Answer: a) One
Explanation:
x matches case 1 directly, outputting "One" and exiting the switch block.
Correct Answer: b) 02
Explanation:
When i=1, continue skips adding 1 to 'out'. The string output is '02'.
Correct Answer: c) 2
Explanation:
The loop body is empty. i increments from 0 to 1, then to 2. At i=2, (2 < 2) is false, ending loop with i = 2.
Correct Answer: a) Middle
Explanation:
a > 5 (10 > 5) is true. Nested condition a < 20 (10 < 20) is also true, returning "Middle".
Correct Answer: a) true
Explanation:
Infinity and -Infinity are non-zero numbers and evaluate as truthy in JavaScript.
Correct Answer: a) xy
Explanation:
The 'for...in' loop iterates over enumerable string property keys of an object, concatenating 'x' and 'y'.
Correct Answer: a) yield
Explanation:
The yield statement pauses generator function execution and produces the value specified.
Correct Answer: a) true
Explanation:
(1 < 2) is true, and (2 < 3) is true. Logical AND returns true.
Correct Answer: b) false
Explanation:
(1 < 2) is true, but (3 < 2) is false. Logical AND evaluates to false.
Correct Answer: b) false
Explanation:
Both conditions (1 > 2) and (3 < 2) evaluate to false, resolving logical OR to false.
Correct Answer: a) It safely jumps out of the labeled block statement.
Explanation:
Labeled break statements can be used with any block statement (not just loops), breaking out of the block early.
Correct Answer: a) 1
Explanation:
When i=0, count increments to 1. When i=1, break terminates loop. Count stays equal to 1.
Related Posts

C++ Control Flow / If-Else MCQs Conditional Statements
Control flow statements determine the execution path of a program based on runtime conditions. In C++, decision-making relies primarily on…
October 20, 2026By MCQs Generator

JavaScript Interview Questions MCQs
JavaScript interview questions evaluate a developer’s deep understanding of core language mechanics, execution models, and advanced runtime behavior. Top tech…
August 29, 2026By MCQs Generator

Java Advanced MCQs
Advanced Java encompasses complex programming paradigms, low-level runtime mechanics, and high-performance framework design beyond standard syntax. It probes deep into…
October 19, 2026By MCQs Generator
Related Categories

AI & Data Science MCQ
5 topics
By MCQs Generator

Arts & Humanities MCQ
4 topics
By MCQs Generator

Civil Engineering MCQ
4 topics
By MCQs Generator

Commerce & Business MCQ
4 topics
By MCQs Generator

Competitive Exams MCQ
5 topics
By MCQs Generator

Electrical & Electronics Engineering MCQ
3 topics
By MCQs Generator

General Knowledge MCQ
2 topics
By MCQs Generator

General Science MCQ
4 topics
By MCQs Generator

Law & Judiciary MCQ
3 topics
By MCQs Generator

Mechanical Engineering MCQ
4 topics
By MCQs Generator

Medical & Health Sciences MCQ
4 topics
By MCQs Generator

Modern Tech Fields MCQ
3 topics
By MCQs Generator