Results for “script”
Small, practical examples. Search by task or narrow things down below.
Reverse a copy while preserving the original
JavaScript: Copy before reverse because reverse mutates the array it receives.
JavaScript✓ Tested
Reverse a copy while preserving the original
TypeScript: Copy before reverse because reverse mutates the array it receives.
TypeScript✓ Tested
Run cleanup after a promise settles
JavaScript: finally runs after success or failure and normally preserves the original outcome.
JavaScript✓ Tested
Run cleanup after a promise settles
TypeScript: finally runs after success or failure and normally preserves the original outcome.
TypeScript✓ Tested
Run dependent async steps in order
JavaScript: Await one result before using it as the input of the next calculation.
JavaScript✓ Tested
Run dependent async steps in order
TypeScript: Await one result before using it as the input of the next calculation.
TypeScript✓ Tested
Run your first program
JavaScript: Start with a complete program that prints one line. Follow the run instructions below.
JavaScript✓ Tested
Run your first program
TypeScript: Start with a complete program that prints one line. Follow the run instructions below.
TypeScript✓ Tested
Select a range of array elements
Bash Scripts: Quote a sliced at-sign expansion to keep each selected element separate.
Bash Scripts✓ Tested
Separate a first item from the remaining items
JavaScript: Array destructuring and a rest element produce named pieces of a sequence.
JavaScript✓ Tested
Separate a first item from the remaining items
TypeScript: Array destructuring and a rest element produce named pieces of a sequence.
TypeScript✓ Tested
Serialize an object
Turn a JavaScript object into JSON text.
JavaScript✓ Tested