Results for “Types & reliable control flow”
Small, practical examples. Search by task or narrow things down below.
Inspect the parsed pieces of a URL
TypeScript: Use URL properties rather than splitting a URL at punctuation.
TypeScript✓ Tested
Iterate with array indices and values
TypeScript: entries provides each position and value without a separate counter.
TypeScript✓ Tested
Keep both matching and rejected values
TypeScript: Use two explicit outputs when a caller needs both sides of a classification.
TypeScript✓ Tested
Lay out a short label in a vertical writing mode
CSS: Writing-mode changes the direction in which lines and inline content are laid out.
CSS✓ Tested
List an object’s own enumerable keys
TypeScript: Object.keys omits inherited and non-enumerable properties.
TypeScript✓ Tested
Map items to multiple output values
TypeScript: flatMap combines mapping and a one-level flattening operation.
TypeScript✓ Tested
Measure a short text value
TypeScript: Read the length of an ASCII string. Non-ASCII text may use multiple code units or bytes depending on the language.
TypeScript✓ Tested
Mutate a struct through a pointer receiver
Mutate a struct through a pointer receiver using a complete Go program with explicit sample inputs.
Go✓ Tested
Name a value that stays fixed
TypeScript: Use a constant declaration or the language’s constant naming convention for a fixed limit.
TypeScript✓ Tested
Normalize identifier case consistently
TypeScript: Use toLowerCase for a simple case-insensitive ASCII identifier lookup.
TypeScript✓ Tested
Pair corresponding array items by position
TypeScript: Validate equal lengths before zipping when missing counterparts would be an error.
TypeScript✓ Tested
Pass values through a custom event
jQuery: trigger passes its extra argument array after the event object.
jQuery✓ Tested