MouseEvent: mouse buttons and modifier keys
Read which mouse button an event concerns and whether Ctrl, Meta, Shift, or Alt was active. Use `buttons`, not `button`, to test which buttons are held.
CKTIS / JavaScript
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
Read which mouse button an event concerns and whether Ctrl, Meta, Shift, or Alt was active. Use `buttons`, not `button`, to test which buttons are held.
Read the cursor position relative to the viewport, update the interface as the mouse moves, and clear state when the cursor leaves an element and its descendants.
Watch selected DOM changes, collect pending records without waiting for the callback, and stop observing with or without keeping the records still in the queue.
Configure `observe()` to track child-list, attribute, or character-data changes. Choose how far observation extends and when records should carry the value from before a change.
Identify what changed and which node was affected, inspect added or removed children, and tell when a record contains the previous value.
`NaN` is a special `Number` value. Use `Number.isNaN()` to detect it without converting the argument, unlike the global `isNaN()` function.
Use `contains()` to check membership in a specific node’s subtree and `isConnected` to check whether a node is connected to a document.
Test whether a node belongs to a subtree, read its parent or first child, insert a node at a specific position, and merge adjacent text nodes.
`contains()` checks whether a node is the same node or a descendant. `parentElement` returns the immediate parent only if that parent is an element.
Tell text nodes from elements, read the value of an individual node, and traverse direct children without overlooking changes to the live list.
Convert a `Number` to text in a base from 2 to 36. Learn how JavaScript selects and coerces the base, and why formatting a number is not the same as parsing text.
Use `[expr](...) { ... }` in an object literal to define a method under a key determined by an expression. The key is a string or a symbol.
Use `obj[expr]` to read or assign a property selected by an expression instead of using a fixed name after a dot.
Use `[expression]: value` to choose a property key when an object is created. The resulting key is a string or a symbol.
Distinguish reading properties from an argument, creating a property from a variable, and defining a method without the `function` keyword.
Object destructuring reads properties from an existing value. Property shorthand goes the other way: it uses variables to create same-named properties on a new object.
An object destructuring declaration creates variable bindings from source properties. The pattern lets you rename bindings, set defaults, and collect the remaining properties.
Read options from one argument, distinguish the whole-parameter default from individual property defaults, and build the result with object property shorthand.
Object destructuring reads properties by key rather than by position. Use it to declare variables, assign to existing targets, provide defaults, or collect remaining properties.
Distinguish binding values from an object, defining properties with shorthand, and accessing properties through keys evaluated at runtime.
Use `get` in an object literal to run a function when a property is read, so the value can reflect the object's current state without an explicit method call.
Write `name(a) {}` to define a method in an object literal. Learn how the call sets `this`, where `super` starts its lookup, and why the method cannot be used with `new`.
Use `method(param) { ... }` to define an object-literal method without `:` or `function`. The call determines `this`, but the method’s definition determines where `super` looks.
Use `method() {}` to define a method directly in an object literal. The call determines `this`, but `super` starts its lookup at the prototype of the object where the method was defined.