FIND YOUR NEXT FEW LINES

Results for “utility type”

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

219 snippets foundClear filters
RustFunctions & data types

Derive comparison and debugging behavior

Derive comparison and debugging behavior in a complete Rust program using the standard library.

Rust✓ 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
CSSType & reading flow

Display a label in uppercase without changing its text

CSS: Text-transform changes visual casing while preserving the DOM’s source text.

CSS✓ 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
GoFunctions & types

Embed a struct for shared fields

Embed a struct for shared fields using a complete Go program with explicit sample inputs.

Go✓ Tested
TypeScriptGetting Started

Explain a calculation with a comment

TypeScript: Keep the code executable while documenting why a fixed input is used.

TypeScript✓ Tested
TypeScriptRegular expressions & URL encoding

Extract all regex matches with their groups

TypeScript: matchAll requires a global regular expression and returns an iterator of matches.

TypeScript✓ Tested
TypeScriptText handling & Unicode

Extract text by start and end positions

TypeScript: String slice uses an inclusive start and exclusive end measured in UTF-16 code units.

TypeScript✓ Tested