Results for “Functions & types”
Small, practical examples. Search by task or narrow things down below.
Run your first program
TypeScript: Start with a complete program that prints one line. Follow the run instructions below.
TypeScript✓ Tested
Separate a first item from the remaining items
TypeScript: Array destructuring and a rest element produce named pieces of a sequence.
TypeScript✓ Tested
Sort timestamp strings by their parsed instants
TypeScript: Compare epoch values explicitly when date strings may contain different offsets.
TypeScript✓ Tested
Split an array into bounded batches
TypeScript: Advance by a positive batch size and allow a shorter final chunk.
TypeScript✓ Tested
Split text on several separator characters
TypeScript: A regex character class can recognize alternative simple delimiters.
TypeScript✓ Tested
Store a value in a named variable
TypeScript: Give a value a descriptive name and print it.
TypeScript✓ Tested
Transform a resolved promise result
TypeScript: A then handler returns the value passed to the next promise in the chain.
TypeScript✓ Tested
Transform each regex match with a callback
TypeScript: A replacement callback computes the replacement separately for each match.
TypeScript✓ Tested
Trim and discard blank lines
TypeScript: Split a text block, trim each line, and keep nonempty values.
TypeScript✓ Tested
Update a running count
TypeScript: Change a variable after its initial value has been assigned.
TypeScript✓ Tested
Use a switch expression to classify a value
C#: Relational patterns express a small ordered range classification.
C#✓ Tested
Use the first fulfilled promise result
TypeScript: Promise.any ignores individual rejections until one input fulfills.
TypeScript✓ Tested