Media playback state and time: paused, muted, currentTime, and duration
Read pause and mute states separately, set a playback position in seconds, and distinguish a known duration from `NaN` and `Infinity`.
CKTIS / JavaScript
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
Read pause and mute states separately, set a playback position in seconds, and distinguish a known duration from `NaN` and `Infinity`.
Distinguish a media element’s current state from its events and from the result of calling `play()`. Tell a pause, natural completion, and a media resource failure apart.
Use nine audio and video events to keep playback position, duration, and controls in sync and to detect a resource reset, playback completion, or a media failure.
Read or set the value of one HTML option. A missing `value` attribute makes the property fall back to the option’s text, but an explicitly empty value stays empty.
`max` sets the total amount of work and `value` sets the amount done. A missing `value` attribute means indeterminate progress, not 0% complete.
`template.content` exposes a template’s inert contents as a `DocumentFragment`. To reuse the template, copy its subtree into the destination document and insert the copy.
Reading `HTMLTextAreaElement.value` returns text with LF line endings, even if the string assigned to it contained CRLF pairs or lone CR characters.
When generating HTML, escape plain text for the position where it will be inserted. When writing directly to an ordinary DOM element, use `textContent` with the original string instead.
Escape characters to display input as literal text. To preserve selected formatting, sanitize the parsed HTML structure using an explicit policy for elements and attributes.
Read the current IndexedDB record from a cursor, then request the next record or use a key to skip ahead in the cursor’s direction.
Use `createObjectStore()` to change the schema during a database upgrade, and `transaction()` to read or write records in existing object stores.
Use `add()`, `getAll()`, `delete()`, and `put()` to work with records by primary key, and distinguish a successful request from a committed transaction.
Create a secondary index during a database upgrade, insert without overwriting, and look up a record by its index key rather than its primary key.
Create a secondary index, insert records without overwriting them, and query by either primary key or index key.
Change an IndexedDB schema in `onupgradeneeded`, get the upgrade transaction from `request.transaction`, and wait for `success` before using the new schema.
Tell when an IndexedDB open request needs a schema upgrade, is waiting for a connection to close, has succeeded, or has failed.
Learn when to read `result` and `error` in IndexedDB and how to tell an individual request's success from a transaction commit.
Read `result` after an IndexedDB request succeeds and `error` after it fails. A successful request does not mean that its transaction has committed.
Use `complete` and `abort` to determine the outcome of a whole IndexedDB transaction, and `error` to diagnose a failed individual request.
`didTimeout` tells you why an idle callback ran; `timeRemaining()` estimates how many milliseconds are left in the current idle period.
An IIFE creates and calls a function in one expression. Grouping parentheses do not call the function; the argument list that follows them does.
Handle image loading success and failure on the image element itself. Register both handlers before setting `src`, and do not treat `complete` as proof of success.
Create a new state without mutating the previous version: copy the containers along the update path and reuse unchanged branches.
Read whether a target intersects the root, how much of its area intersects, and which element was measured. Distinguish intersection state from threshold crossings.