FIND YOUR NEXT FEW LINES

Results for “JavaScript”

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

132 snippets foundClear filters
JavaScriptPromises & iteration protocols

Inspect both successful and failed promise results

JavaScript: allSettled preserves input order and reports failures without rejecting the combined promise.

JavaScript✓ Tested
JavaScriptRegular expressions & URL encoding

Inspect the parsed pieces of a URL

JavaScript: Use URL properties rather than splitting a URL at punctuation.

JavaScript✓ Tested
JavaScriptObjects & JSON

Iterate over object entries

Read JavaScript property names and values using Object.entries.

JavaScript✓ Tested
JavaScriptArray traversal & selection

Iterate with array indices and values

JavaScript: entries provides each position and value without a separate counter.

JavaScript✓ Tested
JavaScriptArray restructuring

Keep both matching and rejected values

JavaScript: Use two explicit outputs when a caller needs both sides of a classification.

JavaScript✓ Tested
JavaScriptObject behavior & collections

List an object’s own enumerable keys

JavaScript: Object.keys omits inherited and non-enumerable properties.

JavaScript✓ Tested
JavaScriptArray restructuring

Map items to multiple output values

JavaScript: flatMap combines mapping and a one-level flattening operation.

JavaScript✓ Tested
JavaScriptGetting Started

Measure a short text value

JavaScript: Read the length of an ASCII string. Non-ASCII text may use multiple code units or bytes depending on the language.

JavaScript✓ Tested
JavaScriptObjects & JSON

Merge object settings

Use object spread to apply JavaScript overrides to defaults.

JavaScript✓ Tested
JavaScriptGetting Started

Name a value that stays fixed

JavaScript: Use a constant declaration or the language’s constant naming convention for a fixed limit.

JavaScript✓ Tested
JavaScriptText handling & Unicode

Normalize identifier case consistently

JavaScript: Use toLowerCase for a simple case-insensitive ASCII identifier lookup.

JavaScript✓ Tested
JavaScriptStrings

Pad a numeric label

Convert a number to text and pad it to a fixed width.

JavaScript✓ Tested