Results for “as”
Small, practical examples. Search by task or narrow things down below.
Read positional parameters in a function
Bash Scripts: Read positional parameters in a function with a small standalone Bash program.
Bash Scripts✓ Tested
Read the beginning of a text value
JavaScript: Extract or display the first three ASCII characters from a known nonempty string.
JavaScript✓ Tested
Read the filename portion of a path
Linux Commands: Read the filename portion of a path using GNU/Linux commands in an empty practice directory.
Linux Commands✓ Tested
Read the final array item with a negative index
JavaScript: at supports negative positions counted from the end.
JavaScript✓ Tested
Read the first array element
Bash Scripts: Read the first array element with a small standalone Bash program.
Bash Scripts✓ Tested
Read the first collection element
JavaScript: Access index zero only after establishing that the collection is nonempty.
JavaScript✓ Tested
Recover from an expected promise rejection
JavaScript: Return a fallback from catch so later handlers receive an ordinary resolved value.
JavaScript✓ Tested
Redirect an entire group of commands
Bash Scripts: Brace grouping runs in the current shell and shares a single output redirection.
Bash Scripts✓ Tested
Refuse to overwrite an existing file with redirection
Bash Scripts: Noclobber makes a plain greater-than redirection fail when the target already exists.
Bash Scripts✓ Tested
Reject a missing required configuration value
Bash Scripts: Check a required value explicitly and emit a controlled diagnostic before exiting.
Bash Scripts✓ Tested
Remove a known prefix with a shell pattern
Bash Scripts: The hash expansion removes the shortest matching prefix without changing the original variable.
Bash Scripts✓ Tested
Remove a Map entry and detect whether it existed
JavaScript: Map.delete returns true only when an entry was present.
JavaScript✓ Tested