First 50 of 200 questions. Each one lists the choices, the correct answer, and an explanation. The checker at the top of this page saves progress in this browser when it is available.
Continue in the practice tool above to load more questions, 50 at a time.
Question 1JavaScript language fundamentals and vendor-neutral certification scope
Which declaration creates a block-scoped binding that cannot be reassigned after initialization?
- const total = 10; Correct answer.
- var total = 10;
- total = 10;
- let total = 10;
Explanation
The const keyword creates a binding scoped to the enclosing block and forbids reassignment after the initializer runs. It does not make the referenced object immutable, only the binding itself.
Question 2JavaScript language fundamentals and vendor-neutral certification scope
What does typeof null evaluate to in JavaScript?
- "object" Correct answer.
- "undefined"
- "boolean"
- "null"
Explanation
typeof null returns the string "object", a long-standing inconsistency retained for backward compatibility. A null check therefore requires an explicit value === null comparison rather than typeof.
Question 3JavaScript language fundamentals and vendor-neutral certification scope
A function is invoked as a plain call inside non-strict code. What does `this` reference inside that function?
- undefined
- The global object Correct answer.
- The function object itself
- A new empty object
Explanation
In sloppy mode a plain function call binds this to the global object, because the call has no receiver. In strict mode the same call would bind this to undefined instead.
Question 4JavaScript language fundamentals and vendor-neutral certification scope
Which value is produced by the expression `0.1 + 0.2 === 0.3`?
- A TypeError is thrown
- NaN
- true
- false Correct answer.
Explanation
Binary floating-point cannot represent 0.1 and 0.2 exactly, so their sum is slightly greater than 0.3 and the strict comparison fails. Comparing with a tolerance such as Number.EPSILON is the usual remedy.
Question 5JavaScript language fundamentals and vendor-neutral certification scope
What is the result of `[1, 2, 3].map(x => x * 2)`?
- [2, 4, 6] Correct answer.
- [1, 2, 3]
- [2, 4, 6, 8]
- 6
Explanation
map invokes the callback once per element, collects each return value, and produces a new array of the same length. The original array is left unchanged.
Question 6JavaScript language fundamentals and vendor-neutral certification scope
Which statement about `let` and `var` inside a for loop body is accurate?
- Neither creates a fresh binding per iteration
- Only var creates a fresh binding per iteration
- Only let creates a fresh binding per iteration Correct answer.
- Both create a fresh binding on each iteration
Explanation
A let declaration in a for loop head creates a new binding for each iteration, which is why closures capture distinct values. var has a single function-scoped binding shared by all iterations.
Question 7JavaScript language fundamentals and vendor-neutral certification scope
Which expression converts the string "42" to the number 42?
- String(42)
- Boolean("42")
- Number("42") Correct answer.
- "42" + 0
Explanation
The Number function performs explicit numeric conversion and returns 42 for this input. The unary plus operator would do the same, but concatenating with the string "0" produces text.
Question 8JavaScript language fundamentals and vendor-neutral certification scope
What does `typeof undefinedVariable` return when the identifier was never declared?
- "undefined" Correct answer.
- "object"
- "null"
- A ReferenceError is thrown
Explanation
typeof is the one operator that tolerates an undeclared identifier, returning the string "undefined" instead of throwing. Evaluating the bare identifier without typeof would raise a ReferenceError.
Question 9JavaScript language fundamentals and vendor-neutral certification scope
Which statement correctly describes how `==` and `===` differ?
- === performs type coercion while == requires matching types
- == performs type coercion before comparison while === requires matching types Correct answer.
- == compares types only while === compares values
- Both always behave identically for primitives
Explanation
The loose equality operator applies the abstract equality algorithm, coercing operands to a common type, whereas strict equality returns false immediately when the types differ. Using === avoids surprising coercions such as "1" == 1 being true.
Question 10JavaScript language fundamentals and vendor-neutral certification scope
What is logged by `console.log([] + {})`?
- "[]"
- "[object Object]" Correct answer.
- A TypeError is thrown
- NaN
Explanation
The + operator converts both operands to primitives; the array becomes the empty string and the plain object becomes "[object Object]". String concatenation then joins them into "[object Object]".
Question 11JavaScript language fundamentals and vendor-neutral certification scope
Inside a method defined with shorthand syntax on an object literal, what does `this` refer to when called as `obj.method()`?
- The global object
- obj Correct answer.
- The prototype of obj
- undefined
Explanation
When a function is invoked as a property of an object, the base object becomes the receiver and this is bound to it. This holds for shorthand methods and for traditional function-valued properties alike.
Question 12JavaScript language fundamentals and vendor-neutral certification scope
Which statement about arrow functions is correct?
- They create a new prototype object
- They bind `this` lexically from the enclosing scope Correct answer.
- They receive their own `arguments` object
- They can be used with the new operator
Explanation
Arrow functions have no this binding of their own and instead capture the this of the surrounding lexical scope. They also lack arguments, prototype, and new-target support, which makes them unsuitable as constructors.
Question 13JavaScript language fundamentals and vendor-neutral certification scope
What is the value of `x` after `let x = 1; { let x = 2; }`?
- 2
- 1 Correct answer.
- undefined
- A SyntaxError is thrown
Explanation
The inner let declares a new binding in the nested block, which shadows the outer one only inside that block. When the block ends the inner binding is gone, leaving the outer x at 1.
Question 14JavaScript language fundamentals and vendor-neutral certification scope
What is the result of `"5" - 2`?
- "52"
- NaN
- 3 Correct answer.
- "3"
Explanation
The subtraction operator only performs numeric arithmetic, so it coerces the string "5" to the number 5 and yields 3. The + operator would instead concatenate because one operand is a string.
Question 15JavaScript language fundamentals and vendor-neutral certification scope
In `function f(a, b = a * 2) {}`, which call is valid?
- f(b = 4)
- f()
- f(3) Correct answer.
- f(3, 4, 5)
Explanation
Default parameters may reference earlier parameters, so calling f(3) evaluates b as 6. Passing extra arguments is also legal in JavaScript, but that does not make the other listed forms specially valid.
Question 16JavaScript language fundamentals and vendor-neutral certification scope
Which statement about `Array.prototype.forEach` is accurate?
- It returns undefined and is used for side effects Correct answer.
- It returns a new array of results
- It skips holes in sparse arrays by throwing
- It stops early when the callback returns false
Explanation
forEach always returns undefined; its purpose is to run a callback for each visited element for side effects. It cannot be short-circuited, unlike a for loop with break or the some and every methods.
Question 17JavaScript language fundamentals and vendor-neutral certification scope
What is logged by `console.log(typeof typeof 1)`?
- "object"
- "string" Correct answer.
- "undefined"
- "number"
Explanation
The inner typeof 1 evaluates to the string "number", and typeof applied to that string yields "string". Operator grouping is right to left here, and typeof always returns a string.
Question 18JavaScript language fundamentals and vendor-neutral certification scope
Which code correctly creates a shallow copy of an array `arr` without mutating it?
- const copy = arr;
- const copy = arr.reverse();
- const copy = arr.sort();
- const copy = arr.slice(); Correct answer.
Explanation
slice with no arguments returns a new array containing the same elements, leaving the source untouched. Assigning the reference or calling mutating methods like reverse and sort would not produce an independent copy.
Question 19JavaScript language fundamentals and vendor-neutral certification scope
What happens when a variable declared with `let` is read inside its temporal dead zone?
- It throws a TypeError
- It throws a ReferenceError Correct answer.
- It reads the value from an outer scope
- It evaluates to undefined
Explanation
A let or const binding exists from the start of its block but is uninitialized until its declaration executes. Accessing it during that window throws a ReferenceError, which is different from var hoisting to undefined.
Question 20JavaScript language fundamentals and vendor-neutral certification scope
Given `const fns = []; for (var i = 0; i < 3; i++) { fns.push(() => i); }`, what does `fns.map(f => f())` return?
- [0, 0, 0]
- [3, 3, 3] Correct answer.
- [0, 1, 2]
- [undefined, undefined, undefined]
Explanation
var creates one function-scoped binding shared by all three closures, and the loop increments it to 3 before any closure runs. Every arrow therefore reads the final value 3. Replacing var with let would give per-iteration bindings and produce [0, 1, 2].
Question 21JavaScript language fundamentals and vendor-neutral certification scope
What is the outcome of `Object.freeze(obj)` followed by `obj.prop = 1` in strict-mode code?
- A TypeError is thrown Correct answer.
- The property is set to 1
- The assignment is silently ignored
- A ReferenceError is thrown
Explanation
Freezing makes existing properties non-writable, and strict mode converts failed writes into thrown TypeErrors. In sloppy mode the same assignment would fail silently instead of throwing.
Question 22JavaScript language fundamentals and vendor-neutral certification scope
What does `[10, 1, 2].sort()` return?
- [1, 10, 2] Correct answer.
- [1, 2, 10]
- [2, 1, 10]
- [10, 1, 2]
Explanation
Without a comparator, sort converts elements to strings and orders them by UTF-16 code units, so "10" precedes "2". A numeric comparator such as (a, b) => a - b is required for numeric ordering.
Question 23JavaScript language fundamentals and vendor-neutral certification scope
Which statement best explains why `NaN === NaN` is false?
- The === operator returns false for all number comparisons
- NaN is coerced to 0 before comparison
- NaN is an object, so identity comparison fails
- The IEEE 754 standard defines NaN as unequal to every value including itself Correct answer.
Explanation
NaN represents an invalid numeric result and by IEEE 754 semantics compares unequal to everything, itself included. Number.isNaN or Object.is(NaN, NaN) must be used to detect it reliably.
Question 24JavaScript language fundamentals and vendor-neutral certification scope
A function returns an inner function that reads a variable declared in the outer function. After the outer function returns, what happens to that variable?
- It becomes undefined
- It remains accessible through the closure Correct answer.
- It is copied into the global scope
- It is garbage collected immediately
Explanation
A closure keeps a reference to the lexical environment in which the inner function was created, so the outer variable survives as long as the inner function is reachable. This is the mechanism behind module patterns and private state.
Question 25JavaScript language fundamentals and vendor-neutral certification scope
What is the value of `1 + 2 + "3"`?
- 6
- "6"
- "123"
- "33" Correct answer.
Explanation
The + operator is left-associative, so 1 + 2 evaluates numerically to 3 first. The next addition involves the string "3", which triggers concatenation and produces "33".
Question 26JavaScript language fundamentals and vendor-neutral certification scope
Which value is produced by the expression `Boolean('0')` in JavaScript?
- NaN
- false
- undefined
- true Correct answer.
Explanation
The Boolean conversion of any non-empty string is true, and the string '0' contains one character, so it is truthy. Only the empty string '' converts to false among strings. This differs from the number 0, which does convert to false.
Question 27JavaScript language fundamentals and vendor-neutral certification scope
Which declaration creates a block-scoped binding that can be reassigned later?
- const count = 0;
- function count() {}
- let count = 0; Correct answer.
- var count = 0;
Explanation
`let` creates a binding scoped to the enclosing block and permits reassignment. `const` is also block-scoped but forbids reassignment of the binding, and `var` is function-scoped rather than block-scoped.
Question 28JavaScript language fundamentals and vendor-neutral certification scope
A developer writes `const s = 'abc'; console.log(s.length);`. What is printed?
- TypeError
- NaN
- 3 Correct answer.
- undefined
Explanation
String primitives expose properties through automatic boxing, so `s.length` reads the number of UTF-16 code units, which is 3 for 'abc'. No error occurs and the value is a number.
Question 29JavaScript language fundamentals and vendor-neutral certification scope
Which operator returns the remainder of a division in JavaScript?
- /
- //
- % Correct answer.
- mod
Explanation
The percent sign `%` is the remainder operator, so `7 % 3` evaluates to 1. It works on numbers and preserves the sign of the dividend.
Question 30JavaScript language fundamentals and vendor-neutral certification scope
What is the result of `typeof null`?
- "undefined"
- "object" Correct answer.
- "null"
- "boolean"
Explanation
`typeof null` returns the string "object" because of a long-standing historical behavior in the language, even though null is its own primitive type. Checking for null therefore requires `value === null` rather than a typeof test.
Question 31JavaScript language fundamentals and vendor-neutral certification scope
Which statement about `Array.isArray` is accurate?
- It returns true for any object with a numeric length property.
- It throws when passed a non-object value such as a number.
- It returns true only for arrays created in the current global context.
- It returns true for arrays created in any realm, such as another iframe. Correct answer.
Explanation
`Array.isArray` performs a brand check that works across realms, so arrays from iframes or other contexts are detected correctly. It returns false for array-like objects and never throws for primitive arguments.
Question 32JavaScript language fundamentals and vendor-neutral certification scope
Which value is returned by `Number.parseInt('12px', 10)`?
- 0
- "12"
- 12 Correct answer.
- NaN
Explanation
`parseInt` reads leading characters that form a valid integer and stops at the first invalid one, so '12px' yields 12. It returns a number, not a string, and only returns NaN when no leading digits exist.
Question 33JavaScript language fundamentals and vendor-neutral certification scope
Which construct creates a new array containing the results of calling a function on every element?
- Array.prototype.filter
- Array.prototype.reduce
- Array.prototype.map Correct answer.
- Array.prototype.find
Explanation
`map` produces a new array of the same length whose entries are the callback return values. `filter` keeps original elements that pass a test, `reduce` collapses to a single value, and `find` returns one element.
Question 34JavaScript language fundamentals and vendor-neutral certification scope
What does `console.log(0.1 + 0.2 === 0.3)` print?
- undefined
- true
- false Correct answer.
- NaN
Explanation
Binary floating point cannot represent 0.1 and 0.2 exactly, so their sum is slightly greater than 0.3 and strict equality fails. The comparison itself returns a boolean, so the output is false.
Question 35JavaScript language fundamentals and vendor-neutral certification scope
Given `const obj = {a: 1}; const copy = {...obj}; copy.a = 2;`, what is `obj.a`?
- 1 Correct answer.
- undefined
- 2
- TypeError
Explanation
The spread syntax creates a new object with copied own enumerable properties, so changing `copy.a` does not affect `obj.a`. The original remains 1 because the two objects are distinct.
Question 36JavaScript language fundamentals and vendor-neutral certification scope
What is logged by `console.log([1, 2, 3].includes(2))`?
- true Correct answer.
- false
- undefined
- 1
Explanation
`Array.prototype.includes` performs a SameValueZero comparison and returns a boolean indicating whether the value is present. Since 2 is an element, it returns true.
Question 37JavaScript language fundamentals and vendor-neutral certification scope
Which statement about the `default` clause of a `switch` statement is accurate?
- It runs in addition to any matching case.
- It must be the final clause in the switch block.
- It is required whenever the switch has more than one case.
- It runs when no case matches, regardless of its position in the switch block. Correct answer.
Explanation
The `default` clause is selected when no case expression matches, and its location within the block does not change that selection. It is optional and does not run alongside a matched case unless fall-through reaches it.
Question 38JavaScript language fundamentals and vendor-neutral certification scope
What does `try { throw new Error('x'); } catch (e) { console.log(e.message); } finally { console.log('done'); }` output, in order?
- done then x
- x then done Correct answer.
- done only
- x only
Explanation
The catch block handles the thrown error and logs its message first, then the finally block always executes and logs 'done'. Both lines are printed in that order.
Question 39JavaScript language fundamentals and vendor-neutral certification scope
Which statement about `Object.keys(obj)` is accurate?
- It returns an array of the object's own enumerable string-keyed property names. Correct answer.
- It returns an array of the property values rather than names.
- It returns a Map of keys to values.
- It returns an array of all property names, including inherited ones.
Explanation
`Object.keys` collects own enumerable string keys into a new array, excluding inherited properties and non-enumerable ones. Use `Object.getOwnPropertyNames` to include non-enumerable keys or `Object.values` for values.
Question 40JavaScript language fundamentals and vendor-neutral certification scope
What is the value of `'5' * '2'`?
- NaN
- '10'
- '52'
- 10 Correct answer.
Explanation
The multiplication operator coerces both string operands to numbers, so '5' and '2' become 5 and 2 and the product is 10. Unlike the plus operator, multiplication has no string concatenation behavior.
Question 41JavaScript language fundamentals and vendor-neutral certification scope
Which statement about `Array.prototype.slice` is accurate?
- It returns the index of the first matching element.
- It reverses the source array and returns it.
- It removes the selected range from the source array in place.
- It returns a shallow copy of the selected range without modifying the source array. Correct answer.
Explanation
`slice` copies the chosen range into a new array and leaves the original untouched. Its shallow nature means object elements are shared by reference between the copy and the source.
Question 42JavaScript language fundamentals and vendor-neutral certification scope
What is logged by `console.log(typeof NaN)`?
- "undefined"
- "object"
- "NaN"
- "number" Correct answer.
Explanation
NaN is a special numeric value of the Number type, so `typeof` reports "number". This is why `Number.isNaN` is preferred over a typeof check for detecting NaN.
Question 43JavaScript language fundamentals and vendor-neutral certification scope
A function is called as `obj.method()` where `method` was assigned an arrow function defined in the outer scope. What does `this` inside that arrow function reference?
- A new empty object
- The `this` value of the enclosing lexical scope where the arrow was created Correct answer.
- `undefined` in all cases
- The object `obj`
Explanation
Arrow functions do not have their own `this`; they capture the `this` of the scope in which they were defined. Calling the arrow as a property of `obj` does not rebind `this` to `obj`.
Question 44JavaScript language fundamentals and vendor-neutral certification scope
What does `console.log(2 ** 3 ** 2)` evaluate to?
- 18
- 64
- SyntaxError
- 512 Correct answer.
Explanation
The exponentiation operator is right-associative, so the expression groups as `2 ** (3 ** 2)`, which is `2 ** 9` and equals 512. Left-associative evaluation would give 64 but is not how the operator behaves.
Question 45JavaScript language fundamentals and vendor-neutral certification scope
Which statement correctly describes the behavior of `for...of` on a string?
- It iterates the string's enumerable property names.
- It cannot be used with strings and throws a TypeError.
- It iterates UTF-16 code units, splitting surrogate pairs.
- It iterates code points, so astral characters such as emoji are yielded as single units. Correct answer.
Explanation
Strings implement the iterable protocol, and their default iterator yields code points rather than raw code units. This means characters outside the Basic Multilingual Plane are produced intact.
Question 46JavaScript language fundamentals and vendor-neutral certification scope
What is the result of `JSON.stringify({a: undefined, b: 1})`?
- {"a":null,"b":1}
- {"a":undefined,"b":1}
- undefined
- {"b":1} Correct answer.
Explanation
Object properties whose values are undefined are omitted entirely during serialization, so only `b` appears in the output. In arrays, by contrast, undefined entries become null.
Question 47JavaScript language fundamentals and vendor-neutral certification scope
Given `const a = [1, 2, 3]; const b = a; b.push(4);`, what is `a.length`?
- undefined
- 3
- TypeError
- 4 Correct answer.
Explanation
Arrays are objects, and assigning `a` to `b` copies the reference rather than the array. Both names therefore point to the same array, so pushing through `b` changes the length seen through `a`.
Question 48JavaScript language fundamentals and vendor-neutral certification scope
What is logged by `console.log([1, 2, 3].reduce((acc, v) => acc + v))`?
- NaN
- undefined
- 0
- 6 Correct answer.
Explanation
With no initial value supplied, `reduce` uses the first element as the accumulator and begins iterating from the second. The result is 1 + 2 + 3, which is 6.
Question 49JavaScript language fundamentals and vendor-neutral certification scope
Which statement about property lookup on an object created with `Object.create(proto)` is accurate?
- `Object.create` copies the prototype's properties onto the new object.
- Assigning a property that exists on the prototype overwrites the prototype's property.
- The prototype chain is not consulted when reading a missing own property.
- Own properties shadow same-named properties found on the prototype chain. Correct answer.
Explanation
Lookup checks own properties first and only then walks the prototype chain, so an own property hides a same-named inherited one. Assignment creates or updates an own property and does not modify the prototype object.
Question 50JavaScript language fundamentals and vendor-neutral certification scope
What does `console.log(Object.is(NaN, NaN))` print?
- false
- NaN
- true Correct answer.
- TypeError
Explanation
`Object.is` uses SameValue semantics, under which NaN is considered equal to itself, unlike the strict equality operator. It also treats +0 and -0 as different, which is another difference from `===`.