Skip to main content

Runtime JavaScript

These are the everyday JavaScript helpers that feel like a tiny Node-style runtime.

Console

console.log('message');
console.warn('warning');
console.error('error');

Console output shows up in your REPL session and over USB serial.

Timers

const timeoutId = setTimeout(() => {
console.log('once');
}, 250);

clearTimeout(timeoutId);

const intervalId = setInterval(() => {
console.log('tick');
}, 500);

clearInterval(intervalId);

Timers are great for LED blinks and polling sensors. Keep intervals short and work lightweight.

Globals

  • process for runtime metadata
  • board for device helpers

Example

console.log(process.version);
console.log(board.name, board.freeMemory());

See Built-in Modules for module APIs like fs, gpio, and adc.

Key terms