Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Accessing Elements

By Index

(get items 0)                        ;; → items[0]
(get items (- items:length 1))       ;; last element

get with a numeric index compiles to bracket access. Colon syntax (items:0) doesn’t work — colons expect property names, not numeric indices.

.at() — Negative Indices

(items:at -1)                        ;; → items.at(-1) — last element
(items:at -2)                        ;; → items.at(-2) — second to last

.at() (ES2022) supports negative indices, counting from the end. Cleaner than (get items (- items:length 1)).

Length

items:length                         ;; → items.length

Searching

(items:includes "Alice")             ;; → items.includes("Alice")
(items:index-of "Bob")               ;; → items.indexOf("Bob")  (-1 if not found)

Note: includes uses SameValueZero comparison (handles NaN correctly). index-of uses === (cannot find NaN).