Text preview & study summary

JavaScript Fundamentals

A free sample of 5 questions from this quiz, shown in full with answer choices and explanations. No interactivity — everything is visible on this page for study and review.

Want to test your knowledge? Launch the Interactive Exam Simulator

Question 1

The JavaScript method used to serialize a JavaScript object into a JSON string is [[blank1]], and the method used to parse a JSON string back into a JavaScript object is [[blank2]].

Explanation

`JSON.stringify(obj)` converts a JavaScript object to a JSON-formatted string (for storage or transmission). `JSON.parse(jsonString)` converts a JSON string back to a JavaScript object. These methods are essential for working with APIs, localStorage, and data serialization. Note: functions, `undefined`, and `Symbol` values are omitted by `JSON.stringify()`.

Question 2

**Statement:** In JavaScript, `===` checks for both **value equality AND type equality** without performing type coercion.

Answer choices

  • A. True (Correct)

  • B. False

Explanation

The strict equality operator `===` (triple equals) compares both value and type without any type conversion. `"5" === 5` returns `false` (string vs. number). The abstract equality operator `==` (double equals) performs type coercion before comparison, which can lead to surprising results like `"5" == 5` being `true`. Best practice is to always use `===`.

Question 3

Which of the following correctly describe **JavaScript prototypal inheritance**? *(Select THREE)*

Answer choices

  • A. Every JavaScript object has an internal `[[Prototype]]` property linking to its prototype (Correct)

  • B. When a property is not found on an object, JavaScript walks up the prototype chain (Correct)

  • C. ES6 `class` syntax introduces a completely new inheritance model, replacing prototypes

  • D. `Object.create(proto)` creates a new object with `proto` as its prototype (Correct)

  • E. The prototype chain ends when an object's `[[Prototype]]` is `null` (Correct)

Explanation

Every JS object has `[[Prototype]]`. When accessing a property not on the object, JS traverses the chain upward. `Object.create()` explicitly sets the prototype. The chain ends at `null` (Object.prototype's prototype). ES6 `class` is syntactic sugar over the same prototypal system—it does NOT introduce a new model. The answer most aligned with the question is A, B, E.

Question 4

In ES6+ JavaScript, to import a specific named export from a module called `utils.js`, you would write: `import { [[blank1]] } from '[[blank2]]';`. To import a default export, you would write: `import [[blank3]] from 'utils.js';` (using any name you choose).

Explanation

ES6 module syntax: `import { namedExport } from './module.js'` imports a specific named export. `import defaultExport from './module.js'` imports the default export (using any name you choose). Modules use `export` (named) and `export default` (default) to expose functionality. This replaces older patterns like CommonJS (`require()`) used in Node.js.

Question 5

In JavaScript, a function that is passed as an argument to another function and is invoked inside that function is called a [[blank1]] function.

Explanation

A callback is a function passed as an argument to another function to be called later, either synchronously (e.g., `Array.forEach()`) or asynchronously (e.g., `setTimeout()`, event handlers). Callbacks were the primary way to handle asynchronous operations before Promises and async/await were introduced. Deeply nested callbacks create "callback hell," which Promises solve.