Built-ins
Every function, browser value, method and global the language gives a program, in one place.
Functions
| Function | Does | Where |
|---|---|---|
|
|
Prints to the console | anywhere |
|
|
Moves to a route; in a static build, a page load | actions, handlers |
|
|
A number, date or money as text, in the locale |
anywhere (chapter 14) |
|
|
"3 minutes ago", "in 2 days" | anywhere |
|
|
A translation, with placeholders and plurals |
anywhere (chapter 21) |
|
|
Switches the locale, and the direction with it | actions, handlers, effects |
|
|
|
actions, handlers |
|
|
A fresh |
anywhere |
|
|
Markup through an allow-list, for |
anywhere (chapter 23) |
|
|
A request through the same engine as |
actions (chapter 17) |
|
|
Shows a change now, takes it back if the action throws |
actions (chapter 17) |
|
|
A small post that survives the page unloading |
anywhere (chapter 18) |
|
|
Plays an animation on a handle |
handlers (chapter 20) |
|
|
Plays an element's own animation again | handlers |
|
|
A repeating and a one-off timer, stopped when their scope leaves |
render blocks (chapter 8) |
|
|
Open a socket, a stream, a channel, a peer — after |
render blocks (chapter 18) |
Browser values
Always in scope and kept current; a state of the same name shadows one.
| Name | Holds |
|---|---|
|
|
|
|
|
the query string, as a map |
|
|
the fragment, without |
|
|
|
|
|
the current |
|
|
|
|
|
|
|
|
the current locale and direction, with i18n configured |
|
|
the route's parameters, by name |
String methods
length, trim(), trimStart(), trimEnd(), toLowerCase(), toUpperCase(), includes(s), startsWith(s), endsWith(s), indexOf(s), lastIndexOf(s), slice(a, b), substring(a, b), charAt(i), at(i), replace(a, b), replaceAll(a, b), split(sep), padStart(n, c), padEnd(n, c), repeat(n), normalize(), localeCompare(other), match(re), search(re) — the browser's — and WebFluent's own:
| Method | Gives |
|---|---|
|
|
The first letter in upper case |
|
|
At most |
|
|
The text without the indentation its lines share |
|
|
A list of its lines |
|
|
A list of its words, split on whitespace |
List methods
length, map(f), filter(f), find(f), findIndex(f), some(f), every(f), includes(x), indexOf(x), reduce(f, init), join(sep), slice(a, b), concat(other), reverse(), sort(f), flatMap(f) — the browser's; push(x) in an action — and WebFluent's own:
| Method | Gives |
|---|---|
|
|
A sorted copy, by what |
|
|
A map from what |
|
|
A copy without repeats |
|
|
The first |
|
|
The first or last item, or |
|
|
The total of a list of numbers |
Every helper runs at build time too, so a static page shows its result.
Number methods
toFixed(n), toString(). Convert with Number("12") and String(n), or "{n}"; round with Math.round, Math.floor, Math.max and the rest.
The built-in types
| Type | Written | Methods and fields |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
the above, |
|
|
|
|
|
|
|
|
|
|
a string |
|
|
|
a string |
|
|
|
|
|
|
|
|
a string's |
|
|
from |
|
|
|
— | none: it may not be shown, spliced, logged or persisted |
.plus and .minus take years, months, weeks, days, hours, minutes, seconds and ms. Durations are written with ms, seconds, minutes, hours, days and weeks. Chapter 13 has the rest.
Browser globals
These compile to themselves, with no prefix: window, document, console, navigator, location, localStorage, sessionStorage, JSON, Math, Date, setTimeout, setInterval, clearTimeout, clearInterval, parseInt, parseFloat, Array, Object, String, Number, Boolean, Promise, Error, Map, Set, RegExp, Infinity, NaN, undefined, encodeURIComponent, decodeURIComponent, encodeURI, decodeURI, atob, btoa, alert, confirm, prompt, requestAnimationFrame, cancelAnimationFrame, history, screen, performance, crypto, globalThis, Intl, Symbol, Reflect, URL, URLSearchParams, FormData, Blob, File, FileReader, Event, CustomEvent, AbortController, TextEncoder, TextDecoder, Notification, matchMedia, getComputedStyle, structuredClone, queueMicrotask. The checker types them as Any, and a name the program declares itself wins over them.
On this page
Functions Browser values String methods List methods Number methods The built-in types Browser globalsChecked by the test suite
Every code block in the guide is parsed, checked and type-checked on each release.