Sum distances with a Euclidean norm
A diagonal is longer than either of its components. Math.hypot combines perpendicular distances without making the caller square each input.
Developer journal
Worked examples, implementation notes and small experiments across ten developer topics.
A diagonal is longer than either of its components. Math.hypot combines perpendicular distances without making the caller square each input.
Path conventions belong to the destination. Use an explicit path flavour when generating portable asset names.
A leaderboard needs an explicit tie policy. Ranking tied scores and sorting their display order are separate decisions.
Day zero of the following month falls on the final day of the requested month. Date handles the year rollover for December.
Replacing just the first delimiter leaves mixed formatting in an identifier. replaceAll makes the intended scope explicit.
JSON text and transport bytes are separate representations. Encode the text as UTF-8 before measuring or sending a byte payload.
An async function call creates a coroutine. A top-level runner supplies the event loop that executes it.
Transposing rows into columns assumes a decision about uneven rows. Ordinary zip stops at the shortest input.
Starred unpacking separates a fixed header from a variable-length tail. It still requires enough elements for the fixed positions.
A page number and offset are the quotient and remainder of the same division. divmod returns both from one operation.
Padding belongs to the display form of an identifier. Keeping IDs as strings preserves meaningful leading zeroes.
Assertions make assumptions visible in tests. Python can disable them in optimized execution, so required input validation deserves an explicit exception.
A fluid container needs a small-screen width and a large-screen maximum. Outer gutters should remain visible at both extremes.
A square ratio reserves equal sides even before media loads. Fit rules decide whether rectangular content is cropped or letterboxed.
Roman numerals change the visual marker style while preserving document order. Longer markers need enough inline space.
A logical minimum inline size protects a component from collapsing beyond its usable width. An overly large minimum can force overflow.
Minimum block size reserves space along the writing mode's block axis. Content can still make the element grow.
Overflow clipping trims paint without providing the scrolling behaviour of a scroll container. This affects how hidden content can be reached.
The selection variant lets a component specify its own selected-text colours. Readability depends on the selected foreground as well as the highlight.
A skew utility changes the painted shape without allocating extra room for the slanted edge. A separate inner wrapper can keep lettering upright.
Flex utilities define the row but children can still resist shrinking. Inspect long labels before adding more breakpoints.
A perforated divider can use an arbitrary background value when a standard border lacks the desired spacing. Keep the pattern in one reusable class list.
A max-width utility constrains a reading column even when its parent occupies the whole viewport. Font size still determines how many characters fit.
Selection utilities can restore copying on one field inside a larger interactive card. Apply the exception to the exact text the reader needs.
Two JSON arrays can be aligned by their integer indexes. An inner join will omit an unmatched tail.
Set operations compare rows under SQL's rules for duplicates. Check whether the result represents membership or the number of occurrences.
Grouping timestamps by day produces counts only for days present in the data. A continuous chart may need a calendar series as well.
LAG retrieves a prior row's value within an ordered window. The first row lacks a predecessor and usually needs its own display rule.
A single-character wildcard expresses a different constraint from a variable-length wildcard. Decide whether punctuation in a search pattern is literal.
An alias defines the name visible to query consumers. It can decouple an API field from a table's internal naming.
Parsing user-provided JSON needs a failure path. Successful parsing alone does not establish that the result has the expected shape.
CRC32 is useful for detecting accidental changes to a byte sequence. Record the input encoding so different producers compute the same checksum.
Performance marks can carry details about the operation they describe. Small stable identifiers are easier to aggregate than large payloads.
Process arguments include runtime and entry-point information before user arguments. Slice off those positions before interpreting input.
An event name can exist without listeners at the point of inspection. Listener checks are snapshots of registration state.
An ASCII check operates on bytes. A string that looks simple after display normalization may still require multibyte encoding.
A numeric type cannot by itself guarantee whole cents. Validate integrality where money enters the typed part of the application.
Reflection across the vertical axis changes the horizontal sign and leaves the vertical coordinate in place. Return a new point when callers retain the original.
A route registry can drive both lookup and allowed route names. Type the keys from the registry so a removed route cannot survive in a separate union.
Indexing a tuple's type by number yields a union of its element types. Literal inference determines how precise that union becomes.
A computed property name derives an object's key from a runtime value. Keep its allowed names narrow if downstream readers expect a fixed set.
References between tasks can be well typed yet point to nonexistent names. Validate membership in the actual set of task IDs as a separate step.
A byline combines authorship and dates without competing with the headline. Use a machine-readable time value alongside the visible date.
An episode transcript serves readers who cannot or prefer not to play audio. Identify speakers in text and keep the transcript easy to navigate.
A split editorial hero needs a deliberate reading order when columns collapse. Place essential copy where it remains intelligible without the accompanying image.
A success message works best beside the action that just completed. Keep it available long enough for someone navigating by keyboard to find it.
A quantity stepper needs minimum and maximum behaviour as well as visible controls. Typed input and button input should converge on the same value.
A full-width divider can separate groups without becoming another heading. Consider whether the boundary is semantic or purely decorative.
A percentage meter needs both a bounded visual fill and a meaningful textual value. Handle a zero denominator before dividing.
Vertical typesetting changes the reading direction and available inline space. Treat the sample text as content so it remains selectable and accessible.
A square image crop gives a card grid consistent geometry. The crop anchor determines whether the most important part of a photo survives.
Batch weight combines quantity and unit weight. Convert all measurements to the same unit before aggregating them.
An ordered milestone summary should preserve the sequence's meaning when names wrap. Use distinct labels for completed, current and upcoming work.
Billing in increments requires a clear rounding policy. Derive the number of blocks before formatting a monetary amount.
Free storage volume depends on consistent dimensions and units. Derive capacity and usage in the same unit before formatting a human-readable summary.
Draft pages need deliberate indexing metadata. An indexing directive controls crawler intent, while access to unpublished material needs a separate permission check.
Allocating a party into groups is an integer problem. The remainder determines whether another group is needed and how full it will be.
Localized links should retain the active language segment. Validate supported locales before inserting user-controlled segments into a destination.
Unit preferences might arrive from a cookie, query or default setting. Validate the chosen value before incorporating it into a label.
A dispatch estimate needs a clear starting date and handling-time rule. Disclose what happens on non-working days if the estimate is shown to customers.