Results for “TypeScript”
Small, practical examples. Search by task or narrow things down below.
Check whether text ends with a suffix
TypeScript: Use endsWith for a literal case-sensitive ending.
TypeScript✓ Tested
Check whether text starts with a prefix
TypeScript: Use startsWith for a literal case-sensitive prefix comparison.
TypeScript✓ Tested
Choose between two branches
TypeScript: Use if and else to handle an available or empty stock count.
TypeScript✓ Tested
Clamp a number between inclusive bounds
TypeScript: Combine Math.min and Math.max when lower is no greater than upper.
TypeScript✓ Tested
Clean up a generator after an early break
TypeScript: Breaking a for-of loop closes a generator and runs its finally block.
TypeScript✓ Tested
Combine text with a name
TypeScript: Construct a greeting from a fixed prefix and a stored name.
TypeScript✓ Tested
Compare a value with a limit
TypeScript: Turn a comparison into a readable yes or no result.
TypeScript✓ Tested
Compare bounded floating-point results with a tolerance
TypeScript: Use an absolute error threshold for values known to be near one.
TypeScript✓ Tested
Compare canonically equivalent Unicode text
TypeScript: Normalize to NFC before comparing equivalent composed and decomposed text.
TypeScript✓ Tested
Concatenate arrays without mutating either input
TypeScript: concat creates a shallow combined sequence.
TypeScript✓ Tested
Construct a date from Unix seconds
TypeScript: Multiply seconds by 1000 before creating a Date.
TypeScript✓ Tested
Consume an asynchronous sequence
TypeScript: for await waits for each value of an async iterator in sequence.
TypeScript✓ Tested