OA. free
Free
MathWorks Core Computer Science Core Computer Science Medium

33.

MathWorks technical mcq question, verified with a worked answer. Free to practise - no sign-up.

JavaScript strict mode**

JavaScript's strict mode is a way to opt in to a restricted variant of JavaScript. Which of the following are true about strict mode? Choose one or more.

Pick ONE OR MORE options

Choose one option.
Show answer & explanation
Answer: A. It makes some silent errors throw errors.

Strict mode converts silent failures into throw errors (A), disallows undeclared variables (B), and allows NaN assignment in non-strict mode (D). Option C is false because strict mode actually REQUIRES function parameters to have unique names—it throws a syntax error if duplicates exist. In non-strict mode, duplicate parameter names are allowed (the last one wins).

Step-by-step Derivation:
Analyze each statement:

A) TRUE: Strict mode changes behaviors that were silent failures in non-strict mode to throw errors. For example, assigning to read-only properties or deleting non-configurable properties throws errors instead of silently failing.

B) TRUE: In strict mode, referencing undeclared variables throws a ReferenceError. Without strict mode, they're implicitly created as global variables.

C) FALSE: This is backwards. Strict mode REQUIRES unique parameter names and throws a SyntaxError if duplicates are found. Non-strict mode allows duplicate names.

D) TRUE: In non-strict mode, NaN, Infinity, and undefined can be reassigned (they're not protected). In strict mode, attempting to assign to NaN throws a TypeError.

Correct answers: A, B, D