Results for “Function scope & composition”
Small, practical examples. Search by task or narrow things down below.
Generate a bounded integer range
TypeScript: Array.from supplies each output position to its mapping function.
TypeScript✓ Tested
Give an optional property a default
Handle missing object fields with nullish coalescing.
optional✓ Tested
Handle a terminating error
Catch conversion failures and produce a clear fallback.
try catch✓ Tested
Handle an expected command failure
Branch on a command’s exit code without aborting the script.
exit status✓ Tested
Identify headers for individual table rows
HTML: Scope row associates the first header cell with the data cells in that row.
HTML✓ Tested
Label a data table
Use a caption and scoped headers for an HTML data table.
HTML✓ Tested
Look up values in an associative array
Use named keys for a small in-memory configuration table.
dictionary✓ Tested
Mark a self-contained article
HTML: Article identifies a standalone composition that can be read independently.
HTML✓ Tested
Measure the length of ordinary text
SQL: Use the engine’s text-length function; this ASCII example has no trailing spaces.
SQL✓ Tested
Measure the length of ordinary text
SQL Server: Use the engine’s text-length function; this ASCII example has no trailing spaces.
SQL Server✓ Tested
Measure the length of ordinary text
Postgres: Use the engine’s text-length function; this ASCII example has no trailing spaces.
Postgres✓ Tested
Measure the length of ordinary text
SQLite: Use the engine’s text-length function; this ASCII example has no trailing spaces.
SQLite✓ Tested