Results for “function”
Small, practical examples. Search by task or narrow things down below.
Create independent rows in a matrix
TypeScript: Use a mapping function to create each row instead of sharing one array with fill.
TypeScript✓ Tested
Describe an object with an interface
Require named fields on a reusable object shape.
interface✓ Tested
Discard incidental output from a setup command
PowerShell: Out-Null prevents setup objects from becoming part of a function or script’s useful result.
PowerShell✓ Tested
Expand a JSON array into rows
Iterate array elements using a table-valued function.
json_each✓ Tested
Generate a bounded integer range
JavaScript: Array.from supplies each output position to its mapping function.
JavaScript✓ Tested
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
Look up values in an associative array
Use named keys for a small in-memory configuration table.
dictionary✓ 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