Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

Knowledge base — JavaScript

Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.

Entries: 1003

JavaScript

Canvas 2D: transforms, rectangles, and paths

Keep the transform, the pixels, and the default path separate. Learn when coordinates are transformed, which calls change pixels immediately, and what remains after `stroke()`.

Advanced · ECMAScript 2024 and the current web platform; runtime support varies
JavaScript

Class constructor and method definitions

Create instances with `new`, initialize their state in `constructor`, and distinguish prototype methods from static methods and `super()` from `super.method()`.

Intermediate · ECMAScript 2024 and the current web platform; runtime support varies
JavaScript

Class constructor and method syntax

A constructor initializes the object created by `new`, instance methods are shared through the prototype, and static methods belong to the class.

Advanced · ECMAScript 2024 and the current web platform; runtime support varies
JavaScript

Class constructor method (`constructor`)

Use `constructor` to set up an object created with `new`. In a derived class, `super()` makes `this` available.

Intermediate · ECMAScript 2024 and the current web platform; runtime support varies
JavaScript

Computed property access

Bracket notation `obj[expr]` selects a property using the value of an expression. Use it to read or write properties or call methods whose keys are determined at runtime.

Advanced · ECMAScript 2024 and the current web platform; runtime support varies
JavaScript

CSSStyleDeclaration: border widths and transform

Set individual border widths and a CSS transform through `element.style`, and distinguish inline declarations from the values the browser resolves after applying the cascade.

Intermediate · ECMAScript 2024 and the current web platform; runtime support varies
JavaScript

CSV tokenizer and parser state machine

Use a finite-state tokenizer to identify CSV fields and a parser to assemble records without splitting at commas or line breaks inside quoted values.

Advanced · ECMAScript 2024 and the current web platform; runtime support varies
JavaScript

Custom element `disconnectedCallback()`

Use `disconnectedCallback()` to release resources tied to a custom element’s connection to a document, while keeping the instance ready to reconnect.

Intermediate · ECMAScript 2024 and the current web platform; runtime support varies
JavaScript

Custom elements: observed attributes and lifecycle callbacks

Learn how a custom element chooses which attributes to observe and how it reacts to attribute writes, connection to a document, and disconnection.

Intermediate · ECMAScript 2024 and the current web platform; runtime support varies
JavaScript

Read and change the UTC year of a Date

`getUTCFullYear()` reads the UTC year. `setUTCFullYear()` changes the same `Date` and returns its new timestamp. Omitting an argument is not the same as passing `undefined`.

Advanced · ECMAScript 2024 and the current web platform; runtime support varies
JavaScript

debounce: run after calls pause

`debounce` combines a burst of calls into one. In the version shown here, only the last call runs, after the calls have paused.

Basic · User-defined debounce helper using web timers; host timer behavior varies
JavaScript

Default parameter syntax

Use `parameter = expression` in a function definition to supply a value when the corresponding argument is omitted or explicitly passed as `undefined`.

Advanced · ECMAScript 2024 and the current web platform; runtime support varies
JavaScript

Destructuring default values

A destructuring default replaces only `undefined`. It preserves `null`, `false`, and `0`, and the fallback expression runs only when needed.

Intermediate · ECMAScript 2024 and the current web platform; runtime support varies
JavaScript

Destructuring function parameters

Put patterns directly in a function’s parameter list to read object properties or values from an iterable. Learn how whole-parameter defaults differ from defaults inside a pattern.

Intermediate · ECMAScript 2024 and the current web platform; runtime support varies
JavaScript

`document.body` vs. `document.documentElement`

Use `document.body` to access the page’s content element and `document.documentElement` to access the document’s root element. Either property can return `null`.

Intermediate · Current web platform; runtime support varies
JavaScript

ID lookup versus focus: getElementById() and activeElement

`document.getElementById(id)` finds an element by its ID, while `document.activeElement` reports where the document sees keyboard focus right now.

Advanced · ECMAScript 2024 and the current web platform; runtime support varies
JavaScript

`document.getElementById()` versus `document.body`

Use `getElementById()` to find an element by its ID, and `document.body` to access the document’s body element whether or not it has an ID.

Advanced · ECMAScript 2024 and the current web platform; runtime support varies