Variables, Types, and Collections23% of the exam

Strings, numbers and dates

The string, number and Date behaviors that decide 'what is logged' questions: immutable strings and slice vs substring, floating-point error and toFixed returning a string, parseInt vs Number, safe integers and BigInt, currency formatting with Intl.NumberFormat, zero-based months, UTC date-only parsing and date arithmetic.

Official exam objective
Given a business requirement, utilize strings, numbers, and dates effectively.

~6 min read · 13 practice questions ·

What the exam expects

  • Predict the result of string methods (slice, substring, replace, padStart, split/join, template literals) and remember that none of them changes the original string.
  • Handle money and IDs: explain 0.1 + 0.2 !== 0.3, know that toFixed() returns a string, and keep integers above Number.MAX_SAFE_INTEGER as strings or BigInt.
  • Choose between Number(), unary +, parseInt() and parseFloat() for strings such as '42px'.
  • Format currency for a locale with Intl.NumberFormat (or toLocaleString with the same options).
  • Build and compare dates: zero-based months, local vs UTC parsing, overflow when setting components, and subtracting dates to get milliseconds.
  • Key terms: immutable (a primitive value can never be changed in place); IEEE 754 double (the 64-bit binary format of every number); safe integer (an integer the format represents exactly, up to 2^53 − 1); timestamp (milliseconds since 1 January 1970 UTC, the value inside every Date); locale (language and region whose formatting rules apply).

Key facts

String methods
Detail
Return new strings; index assignment does not change a string
substring() with a negative argument
Detail
Treated as 0
replace() with a string pattern
Detail
First occurrence only
toFixed()
Detail
Returns a string, rounded and zero-padded
Number('')
Detail
0; Number('42px') is NaN
parseInt radix
Detail
Not always 10 when omitted; pass it
Number.MAX_SAFE_INTEGER
Detail
9007199254740991 (2^53 − 1)
BigInt with number
Detail
Cannot be mixed in arithmetic
Currency format
Detail
style: 'currency' plus a currency code
Month index
Detail
Zero-based: 0 = January, 11 = December
Date-only ISO string
Detail
Parsed as UTC; date-time without offset is local
dateB - dateA
Detail
Difference in milliseconds
Sources for this section (10)
  • Why does `0.1 + 0.2 === 0.3` return `false`?
  • When should a large numeric ID be kept as a string or `BigInt`?
  • Why does `new Date('2025-07-04').getDate()` return 3 in California?
  • Which call formats 1234.5 as `$1,234.50`?
  • What does `'cloud'.toUpperCase()` do to the original string?

The questions are free to read. Answers with their sources and self-grading are included with the pack.

Keep reading with the JavaScript Developer pack

  • Core concepts
  • Exam traps
  • Worked scenario

The pack includes:

  • All 24 lessons of the JavaScript Developer guide, with reading progress
  • Interactive decision walks and step-by-step sequence steppers
  • Inline practice questions and one-click topic practice (13 questions for this lesson)
  • An official source cited for every claim
  • An AI tutor that answers from the guide
  • Unlimited timed practice exams

Practice for the JavaScript Developer exam