MDN self-hosted library · e01.org
Invariant / notebook

Invariant

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

js
let count = 0;
while (hasMessages()) {
  count++;
  processMessage();
}
js
function processInput(input) {
  if (input < 0 || !Number.isInteger(input)) {
    throw new Error("Input must be a non-negative integer");
  }
  // Process input...
}