Skip to content

Instantly share code, notes, and snippets.

@oeo
Created August 18, 2025 21:29
Show Gist options
  • Select an option

  • Save oeo/d935cd75a86eff7cd5689b5bb3805ed3 to your computer and use it in GitHub Desktop.

Select an option

Save oeo/d935cd75a86eff7cd5689b5bb3805ed3 to your computer and use it in GitHub Desktop.
// Prototypical ideas for syntax improvements
// Range loops
for x in [1..10] {
console.log x
}
// List comprehensions
const evens = [x * 2 for x in [1..100] if x % 2 == 0]
// Pattern matching
match value {
case 0 => "zero"
case 1..10 => "small"
case n if n > 100 => "large"
case _ => "medium"
}
// Pipeline operators
const result = data
|> filter(x => x > 0)
|> map(x => x * 2)
|> reduce((a, b) => a + b)
// Guard clauses
guard user.isValid else throw "Invalid user"
// Async do notation
const data = do {
user <- await fetchUser()
posts <- await fetchPosts(user.id)
return { user, posts }
}
// Object spread pattern matching
const {x, y, ...rest} := point
// Optional chaining existential operators with defaults
const name = user?.profile?.name ?? "Anonymous"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment