FIND YOUR NEXT FEW LINES

Results for “Types & reliable control flow”

Small, practical examples. Search by task or narrow things down below.

308 snippets foundClear filters
TypeScriptText handling & Unicode

Repeat a string a fixed number of times

TypeScript: String.repeat requires a nonnegative finite repetition count.

TypeScript✓ Tested
TypeScriptGetting Started

Repeat while a condition holds

TypeScript: Count down while a positive number remains, updating the loop variable on each iteration.

TypeScript✓ Tested
TypeScriptArray restructuring

Replace an array segment in place

TypeScript: splice returns removed items and inserts replacements at the chosen position.

TypeScript✓ Tested
TypeScriptGetting Started

Replace one collection element

TypeScript: Update an existing element at a known valid index.

TypeScript✓ Tested
TypeScriptGetting Started

Require two conditions to be true

TypeScript: Combine a lower and an upper bound to check whether a value is in range.

TypeScript✓ Tested
CSSBox dimensions & overflow

Reserve space for a visible border

CSS: A border adds to the outer dimensions of a content-box element.

CSS✓ Tested
TypeScriptRegular expressions & URL encoding

Resolve a relative URL against a base

TypeScript: A trailing slash makes the final base path component a directory.

TypeScript✓ Tested
jQueryEvent control

Respond to the Enter key

jQuery: Use the event key rather than deprecated numeric key codes.

jQuery✓ Tested
TypeScriptArray restructuring

Reverse a copy while preserving the original

TypeScript: Copy before reverse because reverse mutates the array it receives.

TypeScript✓ Tested
TypeScriptPromises & iteration protocols

Run cleanup after a promise settles

TypeScript: finally runs after success or failure and normally preserves the original outcome.

TypeScript✓ Tested
TypeScriptPromises & iteration protocols

Run dependent async steps in order

TypeScript: Await one result before using it as the input of the next calculation.

TypeScript✓ Tested
TypeScriptGetting Started

Run your first program

TypeScript: Start with a complete program that prints one line. Follow the run instructions below.

TypeScript✓ Tested