Strings, numbers and text
This part of the JavaScript course starts with numbers: one type serves integers and fractions, so 0.1 + 0.2, the safe integer range and BigInt come first, with the rounding of Math. Strings follow: the three quote styles, length and indexing, the search and slice methods, and a text built with repeat, padStart and split. A string is a sequence of UTF-16 code units, which is what the Unicode lesson measures, and a template literal puts a value into text. Regular expressions, replacement patterns, JSON and Intl end the part.
3.1
Numbers: one type and floating point
one number type for integers and fractions, 0.1 + 0.2 and the stored digits, Number.EPSILON and a relative tolerance, toFixed for text with fixed decimals
Open
3.2
Integers, the safe range and BigInt
MAX_SAFE_INTEGER and the rounding above it, the BigInt literal and its arithmetic, the TypeError of mixed arithmetic, integer division and the JSON refusal
Open
3.3
Math and rounding
round, floor, ceil and trunc on negative values, min and max with no arguments and with a spread array, random and its range, rounding to a number of decimals
Open
3.4
Strings: quotes, length and indexing
the three quote styles and escapes, length and indexing with brackets and at, the TypeError of a write to an index, conversion between text and numbers
Open
3.5
Searching and slicing strings
includes and the index functions, slice with negative positions, substring that swaps its arguments, reading a file name apart
Open
3.6
Building text: repeat, pad and split
concatenation with plus and +=, repeat with its RangeError, padStart and padEnd, trim and case, split and join
Open
3.7
Unicode, code units and length
code units against code points, the two units of an emoji, Array.from and for...of as the code point loop, Intl.Segmenter for grapheme clusters
Open
3.8
Template literals
interpolation of expressions, multi-line text that keeps its indentation, one tagged template and its parts array, String.raw for a path
Open
3.9
Regular expressions: test, match and the g flag
a literal and test, match with and without the flag, the lastIndex state that makes a global test alternate, exec in a loop against matchAll
Open
3.10
Replacing with patterns and capture groups
replace against replaceAll, a pattern with the g flag and the TypeError without it, $1 and $<name> references, a replacement function
Open
3.11
JSON: stringify, parse and what it cannot hold
stringify with indentation and a replacer, parse with a reviver for a date, the values JSON drops or turns into null, a cycle and a bigint that throw
Open
3.12
Intl: formatting numbers and dates
NumberFormat with a fixed locale, currency, percent and compact notation, DateTimeFormat with a fixed time zone, formatToParts and one formatter reused
Open