Results for “Types & reliable control flow”
Small, practical examples. Search by task or narrow things down below.
Percent-encode one URL component
TypeScript: encodeURIComponent escapes a parameter value rather than a complete URL.
TypeScript✓ Tested
Place fixed-size boxes on the same line
CSS: Inline-block allows dimensions while participating in inline layout.
CSS✓ Tested
Preserve line breaks while collapsing repeated spaces
CSS: Pre-line retains newlines but does not preserve all whitespace like pre-wrap does.
CSS✓ Tested
Prevent navigation from a handled link
jQuery: preventDefault cancels the browser action without cancelling event bubbling.
jQuery✓ Tested
Prevent runtime changes to top-level properties
TypeScript: Object.freeze prevents ordinary top-level mutations; Reflect.set reports the rejected update without throwing.
TypeScript✓ Tested
Print a number with two decimal places
TypeScript: Format a small decimal value consistently for display.
TypeScript✓ Tested
Produce a lazy sequence with a generator
TypeScript: A generator yields one value per iteration without building an intermediate array.
TypeScript✓ Tested
Read a handler result without event bubbling
jQuery: triggerHandler invokes the first matched element’s handlers without native default behavior.
jQuery✓ Tested
Read a selection when its change event fires
jQuery: A change handler observes the current selected value.
jQuery✓ Tested
Read an ISO-style weekday number
TypeScript: Convert Sunday from zero to seven when using Monday-through-Sunday numbering.
TypeScript✓ Tested
Read an object’s own enumerable values
TypeScript: Object.values provides values without their corresponding keys.
TypeScript✓ Tested
Read date components in UTC
TypeScript: UTC accessors avoid differences caused by the machine’s local timezone.
TypeScript✓ Tested