FIND YOUR NEXT FEW LINES

Results for “as”

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

2533 snippets foundClear filters
JavaScriptUTC date operations

Detect an invalid Date object

JavaScript: An invalid Date has a NaN time value.

JavaScript✓ Tested
JavaScriptNumbers & numeric validation

Detect NaN without converting the input

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

JavaScript✓ Tested
ReactAsync work & status

Disable an action while it is pending

Disable an action while it is pending with a small React component and explicit browser behavior.

React✓ Tested
JavaScriptNumbers & numeric validation

Display a number with a fixed decimal width

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

JavaScript✓ Tested
Bash ScriptsDiagnostics & defensive scripting

Distinguish an empty input line from end of input

Bash Scripts: A successful read can return an empty value; its status indicates whether a line was read.

Bash Scripts✓ Tested
JavaScriptObject behavior & collections

Distinguish an own property from an inherited one

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

JavaScript✓ 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
Bash ScriptsParameter expansion

Distinguish unset variables from empty strings

Bash Scripts: Omitting the colon tests only whether a variable is unset; including it also treats an empty value as missing.

Bash Scripts✓ Tested
JavaScriptGetting Started

Divide using a fractional number

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

JavaScript✓ Tested
JavaScriptNumbers & numeric validation

Drop the fractional part toward zero

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

JavaScript✓ Tested
C#Asynchronous work & URI handling

Escape a URL query value

C#: EscapeDataString percent-encodes one value rather than an entire URL.

C#✓ Tested
C#Asynchronous work & URI handling

Escape text for an HTML context

C#: HtmlEncode converts markup delimiters in plain text before rendering it as HTML content.

C#✓ Tested