FIND YOUR NEXT FEW LINES

Results for “Functions & data types”

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

787 snippets foundClear filters
TypeScriptRegular expressions & URL encoding

Decode a percent-encoded URL component

TypeScript: decodeURIComponent reverses percent encoding and throws for malformed sequences.

TypeScript✓ Tested
RustParsing & byte data

Decode bytes as validated UTF-8

Decode bytes as validated UTF-8 in a complete Rust program using the standard library.

Rust✓ Tested
TypeScriptPromises & iteration protocols

Delegate iteration to another iterable

TypeScript: yield-star forwards items from another iterable while retaining generator composition.

TypeScript✓ Tested
JavaFile operations & binary data

Delete a known temporary file if present

Java: deleteIfExists returns whether a file was removed and still reports other I/O errors.

Java✓ Tested
TypeScriptUTC date operations

Detect an invalid Date object

TypeScript: An invalid Date has a NaN time value.

TypeScript✓ Tested
TypeScriptNumbers & numeric validation

Detect NaN without converting the input

TypeScript: Number.isNaN tests the special numeric value instead of applying string-to-number conversion.

TypeScript✓ Tested
PowerShellFunctions & parameter validation

Dispatch values with wildcard patterns

PowerShell: Switch -Wildcard interprets shell-style matching patterns for each clause.

PowerShell✓ Tested
TypeScriptNumbers & numeric validation

Display a number with a fixed decimal width

TypeScript: toFixed returns a formatted string rather than a numeric value.

TypeScript✓ Tested
TypeScriptObject behavior & collections

Distinguish an own property from an inherited one

TypeScript: Object.hasOwn avoids depending on an object’s possibly shadowed hasOwnProperty method.

TypeScript✓ Tested
TypeScriptGetting Started

Divide using a fractional number

TypeScript: Use a floating-point operand to preserve the fractional part of a division.

TypeScript✓ Tested
TypeScriptNumbers & numeric validation

Drop the fractional part toward zero

TypeScript: Math.trunc differs from floor for negative inputs.

TypeScript✓ Tested
RustParsing & byte data

Encode an integer as big-endian bytes

Encode an integer as big-endian bytes in a complete Rust program using the standard library.

Rust✓ Tested