Code Samples — Multiple Languages
Code Samples
JavaScript
// Simple debounce examplefunction debounce(fn, wait) { let t; return function(...args) { clearTimeout(t); t = setTimeout(() => fn.apply(this, args), wait); };}
console.log('debounce ready');Python
def fib(n): a, b = 0, 1 for _ in range(n): a, b = b, a + b return a
print(fib(10))Rust
fn main() { let v = vec![1, 2, 3]; for x in v.iter() { println!("{}", x); }}Shell
#!/usr/bin/env bashecho "Hello from shell"SQL
SELECT id, title FROM posts WHERE published = true ORDER BY date DESC LIMIT 10;Expressive Code Features
Expressive Code provides enhanced code block features including titles, line numbers, highlighting, and more.
Code Block with Title and Line Numbers
// Simple debounce examplefunction debounce(fn, wait) { let t; return function(...args) { clearTimeout(t); t = setTimeout(() => fn.apply(this, args), wait); };}
console.log('debounce ready');Highlighted Lines
def fib(n): a, b = 0, 1 for _ in range(n): a, b = b, a + b return a
print(fib(10))Collapsed Code Block
fn main() { let v = vec![1, 2, 3]; for x in v.iter() { println!("{}", x); }}