FIND YOUR NEXT FEW LINES

Results for “common”

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

142 snippets foundClear filters
TypeScriptGetting Started

Name a value that stays fixed

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

TypeScript✓ Tested
SQLJoins & subqueries

Name an intermediate query with a CTE

Make a filtered result reusable within one statement.

CTE✓ Tested
TypeScriptTypes & functions

Narrow a union using typeof

Handle text and numeric values with separate branches.

union✓ Tested
TypeScriptText handling & Unicode

Normalize identifier case consistently

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

TypeScript✓ Tested
TypeScriptArray traversal & selection

Pair corresponding array items by position

TypeScript: Validate equal lengths before zipping when missing counterparts would be an error.

TypeScript✓ Tested
TypeScriptRegular expressions & URL encoding

Percent-encode one URL component

TypeScript: encodeURIComponent escapes a parameter value rather than a complete URL.

TypeScript✓ Tested
TypeScriptObject behavior & collections

Prevent runtime changes to top-level properties

TypeScript: Object.freeze prevents ordinary top-level mutations; Reflect.set reports the rejected update without throwing.

TypeScript✓ Tested
TypeScriptGetting Started

Print a number with two decimal places

TypeScript: Format a small decimal value consistently for display.

TypeScript✓ Tested
JavaText validation & formatting

Process the lines of an in-memory string

Java: Use String.lines to handle common line terminators without retaining them.

Java✓ Tested
TypeScriptPromises & iteration protocols

Produce a lazy sequence with a generator

TypeScript: A generator yields one value per iteration without building an intermediate array.

TypeScript✓ Tested
TypeScriptSafe data handling

Read a nested optional value

Avoid dereferencing a missing nested object.

optional chaining✓ Tested
TypeScriptUtilities & async

Read a property with keyof

Keep the key and returned value tied to an object type.

keyof✓ Tested