Skip to content
Chapter 1Lesson 7

Quiz - The JavaScript value model

Quiz progress

0 / 0

Which of these lines throws a TypeError at runtime?

const config = { feature: true, env: { tier: 'pro' } };
config.feature = false; // A
config.env.tier = 'free'; // B
config = { feature: false }; // C
Only line A.
Only line C.
Lines A and C.
All three.

You spread a nested object to make a “copy” before mutating it:

const original = { name: 'Ada', address: { city: 'London' } };
const copy = { ...original };
copy.address.city = 'Paris';

What does original.address.city hold after this runs?

'London' — the spread copied the whole structure, so the mutation stays on copy.
'Paris' — spread is shallow; copy.address and original.address are the same object.

For which of these values would a senior reach for BigInt rather than a regular number?

A user’s shopping cart total in USD.
A 64-bit Snowflake ID coming back from an external API.
The number of unread notifications on a user’s account.
A nanosecond-resolution counter accumulated across a multi-year telemetry pipeline.

A bio field has a “280-character” limit. The user types 280 emoji, each of which they perceive as one character, and gets rejected as “too long.” Which check belongs in the validator?

input.length <= 280
[...input].length <= 280
[...new Intl.Segmenter('en', { granularity: 'grapheme' }).segment(input)].length <= 280

Two database rows come back with identical contents:

const a = { id: 1, name: 'Ada' };
const b = { id: 1, name: 'Ada' };
console.log(a === b);

What prints, and why?

true=== walks the object and compares each property.
false=== on objects compares the reference (the allocation), not the shape; a and b are two separate allocations.
false=== only works on primitives; comparing objects always returns false.

Why does Drizzle’s sql`SELECT * FROM users WHERE id = ${userId}` resist SQL injection, while `SELECT * FROM users WHERE id = '${userId}'` does not?

The sql tag escapes the value as a string before splicing it into the query text.
The sql tag receives the static segments and the dynamic values separately, and sends the values to the database as bound parameters — they never become part of the SQL text.
Plain backticks evaluate ${userId} at runtime; sql-tagged backticks evaluate it lazily, so injection can’t happen.

Quiz complete

Score by topic