
































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

































Domain 1: Variables, Types, and Collections (Q1–Q69)
Answer: B Rationale: typeof null returns "object", a long-standing quirk of JavaScript. To check for null, use strict equality (value === null).
Answer: B Rationale: Arrays are objects in JavaScript, so typeof [] is "object". Use Array.isArray() to reliably check for arrays.
Answer: B Rationale: With +, if either operand is a string, JavaScript performs string concatenation. 1 + '2' produces the string "12".
Answer: B
Rationale: The - operator performs numeric subtraction, coercing the string '3' to the number 3. The result is 2.
Answer: A, C, E Rationale: The falsy values in JavaScript are false, 0, -0, 0n, "", null, undefined, and NaN. The string '0' and the empty array [] are truthy.
Answer: B Rationale: filter returns a new array of items that pass the test, and map transforms each item. forEach returns undefined; splice mutates the original array; the map option leaves null entries.
Answer: B Rationale: JSON.stringify omits properties with undefined values from the resulting JSON string.
Answer: B
C. undefined D. 0
Answer: A Rationale: The string '0' is non-empty and therefore truthy. Only the empty string '' is falsy among strings.
Answer: A Rationale: push() appends elements to the end of an array and returns the new length.
Answer: A Rationale: pop() removes and returns the last element of an array.
Answer: B Rationale: filter() returns a new array containing only elements for which the callback returns true.
Answer: C
Rationale: reduce() applies a reducer function across an array to produce a single accumulated value.
Answer: B Rationale: let and const are block-scoped, meaning they are confined to the nearest enclosing block. var is function-scoped.
Answer: A Rationale: Hoisting is JavaScript's behavior of moving declarations (not initializations) to the top of their containing scope during compilation.
Answer: B Rationale: NaN is not equal to itself. Use Number.isNaN() to test for NaN.
Answer: A Rationale: Map is a constructor and must be instantiated with new Map().
Answer: A Rationale: The array is coerced to '' and the object to '[object Object]', producing the string '[object Object]'.
Answer: B Rationale: At the start of a statement, {} is parsed as a block, and +[] coerces the array to 0. The result is 0.
Answer: B Rationale: === compares both value and type without coercion. == performs type coercion.
Answer: A Rationale: With loose equality (==), null and undefined are considered equal. With strict equality (===), they are not.
D. Throws an error
Answer: B Rationale: Strict equality requires both value and type to match. null and undefined are different types.
Answer: A Rationale: parseInt() parses a string and returns an integer. parseFloat() returns a floating- point number.
Answer: B Rationale: Modern JavaScript treats strings starting with 0 as decimal unless a radix is specified. parseInt('08') returns 8.
Answer: A Rationale: Number('') converts the empty string to 0.
Answer: B Rationale: Number() returns NaN when the string cannot be converted to a valid number.
Rationale: join() concatenates array elements into a single string, separated by a specified delimiter.
Answer: B Rationale: getTime() returns the numeric value of the date in milliseconds since the Unix epoch.
Answer: A Rationale: getMonth() returns the month as a zero-based index (0 = January, 11 = December).
Answer: B Rationale: The length property returns the number of elements in the array.
Answer: B Rationale: The length property returns the number of characters in the string.
D. join()
Answer: A Rationale: slice() returns a shallow copy of a portion of an array into a new array without modifying the original.
Answer: B Rationale: splice() mutates the original array by removing, replacing, or adding elements.
Answer: B Rationale: indexOf() returns the first index at which the specified element is found, or -1 if not present.
Answer: B Rationale: includes() checks whether an array contains a specified element and returns a boolean.
Answer: A Rationale: Array destructuring uses square brackets: const [a, b] = [1, 2];.
Rationale: const prevents reassignment of the binding, but the object's properties can still be mutated unless the object is frozen with Object.freeze().
Answer: A Rationale: Object.freeze() makes an object immutable, preventing addition, deletion, or modification of properties.
Answer: B Rationale: Object.keys() returns an array of the object's own enumerable property names.
Answer: C Rationale: Object.entries() returns an array of [key, value] pairs for the object's own enumerable properties.
Answer: B Rationale: Due to floating-point precision, 0.1 + 0.2 is not exactly 0.3, so the strict equality comparison returns false.
Answer: C Rationale: The exponentiation operator `` raises the first operand to the power of the second: 3 = 8.
Answer: A Rationale: The modulo operator % returns the remainder of a division operation.
Answer: B Rationale: 10 % 3 returns the remainder 1.
Answer: B Rationale: Number.isNaN() reliably checks whether a value is NaN without coercing the argument. Global isNaN() coerces the argument first.
Answer: B
B. To store large numbers C. To represent null D. To convert strings to numbers
Answer: A Rationale: Symbols are primarily used as unique property keys that avoid name collisions.
Answer: B Rationale: reverse() mutates the original array by reversing its elements in place and returns the same array.
Domain 2: Objects, Functions, and Classes (Q70–Q144)
A. 5 B. 10 C. undefined D. ReferenceError
Answer: D Rationale: The let x inside test() creates a temporal dead zone. Accessing x before its declaration within the same scope throws a ReferenceError.
A. 5 B. 10 C. undefined D. ReferenceError
Answer: C Rationale: var x inside test() is hoisted to the top of the function, so console.log(x) prints undefined before the local assignment.
Answer: A Rationale: A closure is a function bundled with its lexical environment, allowing it to access outer-scope variables even after the outer function has finished executing.
Answer: A Rationale: In non-strict mode, this in a standalone function call refers to the global object (e.g., window in browsers). In strict mode, it is undefined.
Answer: B Rationale: Arrow functions do not have their own this; they inherit this from the enclosing lexical scope.
Answer: A Rationale: new creates a new empty object, links it to the constructor's prototype, binds this to the new object, and executes the constructor.
Answer: A Rationale: Every JavaScript object has a prototype, which is an object from which it inherits properties and methods.
Answer: A Rationale: Object.create() creates a new object using the specified object as its prototype.
Answer: A Rationale: ES6 introduced the class keyword for defining classes with a cleaner syntax.
Answer: A Rationale: The constructor method is called automatically when a new instance is created and is used to initialize the object.
B. class Child inherits Parent {} C. class Child : Parent {} D. class Child = Parent {}
Answer: A Rationale: The extends keyword is used to create a subclass that inherits from a parent class.
Answer: A Rationale: super() invokes the constructor of the parent class and must be called before using this in a subclass constructor.
Answer: A Rationale: Static methods are defined with the static keyword and are called on the class itself, not on instances.
A. 1 B. 2 C. undefined D. Throws an error
Answer: B