Loose Equality Coerces Before Comparing
== converts both sides before comparing so strings, arrays and booleans can equal numbers, while === never converts and Object.is alone finds NaN.
Page 19 of 50
== converts both sides before comparing so strings, arrays and booleans can equal numbers, while === never converts and Object.is alone finds NaN.
Map.delete removes one key and reports whether it existed while clear drops everything at once, and setting a value to undefined keeps the key present.
Concatenating map entries lets later layers win, and a resolveConflict callback upgrades the merge into a per-key policy for layered configuration.
Rebuilding each level along a changed path with spread keeps untouched branches reference-identical, so equality checks and memoization stay cheap.
Insertion-order keys make equal objects serialize differently; recursively sorting keys before JSON.stringify yields one canonical string per value.
Primitives get wrapper methods through temporary boxing, but values created with new are objects: different typeof, strict equality fails, Symbol refuses new.
instanceof answers true for every ancestor on the prototype chain, Object.getPrototypeOf walks it hop by hop, and hasOwn ignores inherited members entirely.
scrollTop plus clientHeight against scrollHeight reports the pixels remaining to the bottom, the signal infinite scroll uses before fetching more rows.
selectionStart and selectionEnd expose the highlighted span inside an input, while getSelection with a Range reads text selected anywhere on the page.
split accepts a regex so alternation splits on several separators at once, capture groups keep the separators, and the limit argument caps the piece count.
substring clamps out-of-range and negative indices and swaps reversed arguments, while slice counts negatives from the end and returns an empty string instead.
switch compares with strict equality so a string status never hits a number case, and deliberately omitted breaks group neighboring cases into one branch.
toPrecision keeps a total digit count and switches to exponential notation when digits run out, while toFixed pins decimal places and never abbreviates.
finally always runs after try or catch, a return written inside it replaces the value already computed, and local changes there cannot alter a settled result.
any stops at the first truthy item and all at the first falsy one, empty inputs default to False and True, and next() finds the decisive item itself.
bytearray is the mutable twin of bytes: slices reassign fixed-width fields, single bytes read as integers, and str conversion always names an encoding.
collections.abc classes answer isinstance for any object exposing the right protocol, and Sequence.register accepts unrelated classes as virtual subclasses.
Tallying occurrences into a counts array replays values in order with zero pairwise comparisons, in O(n + max_value) time for small known ranges.
A class with __iter__ returning self and __next__ raising StopIteration plugs into for-loops, iter(), and next() like any builtin sequence.
isoformat() renders an aware datetime and fromisoformat() parses it back losslessly; Python 3.11 also accepts the web-style Z suffix and explicit offsets.
get_close_matches ranks known strings by similarity with a cutoff floor, turning mistyped CLI commands into a did-you-mean suggestion list.
html.escape turns angle brackets, ampersands, and quotes into entities so untrusted text stays inert, and unescape reverses the mapping on read-back.
int(text, base) reads digits in the given radix, base 0 trusts 0b/0o/0x prefixes, and format or bin/oct/hex write integers back out in any base.
tee clones a single-pass iterator into independent cursors that each see the full stream, buffering whatever one branch reads ahead of the other.
indent renders readable trees, compact separators squeeze bytes onto one line, and sort_keys makes equal dicts serialize byte-identically.
math.comb counts unordered picks, math.perm counts ordered ones, k greater than n yields 0 instead of an error, and negative inputs raise ValueError.
A monotonic stack of unresolved indices answers the next strictly larger value for every position in one linear pass instead of scanning right repeatedly.
methodcaller(name, *args) builds a reusable callable that invokes one method with fixed arguments on every item, turning dict.get calls into sort keys.
The three-argument pow(x, y, mod) keeps intermediate values small where x**y would explode, and pow(x, -1, mod) computes a modular inverse or raises ValueError.
A backreference re-matches exactly what its group captured: repeated words fail a lint, quote pairs must close with the same character, keys equal values.
re.escape turns every metacharacter in untrusted text into a literal, so a dot searches for a dot instead of any character and composed templates stay exact.
By default ^ and $ match whole-string ends only; MULTILINE moves them to every line break while DOTALL lets a dot cross newlines to span several lines.
The re.VERBOSE flag ignores whitespace and # comments inside a pattern, so multi-line regexes document their groups and still match exactly the same text.
Slices clamp out-of-range bounds instead of raising, negative indices count from the end, slice objects are reusable by name, slice assignment resizes lists.
linear_regression returns slope and intercept in one call and correlation rates the fit, so predictions and linearity checks need no external packages.
io.StringIO wraps a string as an in-memory text stream, so print(file=...) and csv writers redirect into a buffer instead of touching the filesystem.
super() calls the next class in the C3 linearization rather than a fixed parent: mixin order decides the chain and conflicting orders fail at definition.
Workers wait on one shared Event flag: wait(timeout) sleeps without busy looping, set() wakes every waiter at once, and join() confirms the shutdown.
Borrow a mutable inner value straight out of an Option with as_deref_mut, editing &str in place while None stays None.
Promote a one-shot heap map to a program-lifetime static table with Box::leak, trading an allocation for read-only global lookup without cloning.
Aggregate hits in a BTreeMap whose natural key order makes reports deterministic, with range iteration and entry upserts and no explicit sorting step.
Read a BufReader in zero-copy chunks with fill_buf and consume, bounding each read to the buffer capacity instead of allocating a Vec per segment.
Collect a mapped iterator into Result<Vec<i32>, _>: one bad element short-circuits the whole collect with the first error and leaves no partial vector.
Match against named constants with path patterns, and see why a lowercase identifier in the same position silently becomes an always-matching binding.
Mark one enum variant with #[default] so derive(Default) selects it, and Settings::default() starts in a sane state.
Pass &String as &str through deref coercion: Box<String> and &Vec also coerce, so function boundaries take &str or slices without callers copying.
Implement a Hasher with FNV-1a and hand BuildHasherDefault to HashMap so two identical builds share one bucket layout instead of seeded per instance.
Classify floats with f64::classify and match FpCategory: NaN, infinite, zero, subnormal, and normal each get an arm.
Read and mutate slices without panics: get returns Option<&T>, get_mut returns Option<&mut T>, and plain indexing stays for provably in-bounds access.
Take disjoint mutable borrows of two HashMap entries in one call with get_many_mut, so transfers can hold both sides at once.
Implement the Write trait for a counting sink that tallies bytes and newlines, returning the consumed length that write! and write_all rely on.
Wrap arbitrary failure strings into a real io::Error with Error::other, then classify both custom and filesystem errors by their ErrorKind.
Pick the iteration mode deliberately: iter borrows read-only, iter_mut borrows mutable for in-place edits, into_iter consumes and hands out ownership.
Override size_hint on a custom iterator so collect reserves capacity up front, and compare it with a wrapper that hides the hint and grows as it pushes.
Chain filter and map without doing work: adapters build a pipeline that collect, sum, or a for loop drives, so no intermediate collections appear.
Flatten nested sequences in one pass with flat_map: pages of items or comma-split lines collapse into a single iterator and empty inner values vanish.
Apply the elision rules that let one-input functions and methods omit lifetimes, and see why picking one of two borrows still needs an explicit lifetime.
Fold consecutive exit codes into named bands with range patterns: literal ranges like 64..=78 become match arms, and char ranges classify tokens too.
Show drop glue in action and skip it deliberately with std::mem::forget, which consumes a value without running Drop and leaks its heap allocations.
Split Option handling into two closures with map_or_else so the fallback runs only on None, unlike unwrap_or_else where the default is built first.
Iterate an Option directly: Some yields one element, None yields none, and flatten collapses Option layers inside pipelines.
Hand one Vec through take-by-value stages with zero clones; after each move the previous binding is dead, and reusing it is a compile-time E0382 error.
Check palindromes by comparing chars() against chars().rev(), exercising DoubleEndedIterator equality without allocating a reversed copy.
Locate first and last matching indexes with position and rposition, composing parse-failing predicates via is_ok so unparseable entries are skipped.
Read the OS error number behind an io::Error with raw_os_error, and build one back with from_raw_os_error for a faithful round trip.
Let several parents share child nodes through Rc<RefCell<Vec>>: Rc clones share ownership without copying, RefCell mutates inside an immutable shell.
Bind struct fields with ref and ref mut so a pattern borrows in place instead of moving values out, then compare that with borrowing the scrutinee up front.
Take full ownership of removed map data with HashMap::remove_entry, which returns the key and value instead of dropping the key.
Ignore middle elements with rest patterns: .. binds prefixes, suffixes, or both ends, and match dispatches unknown-length slices by shape.
Use Result::inspect_err to log a failure while forwarding the same Result, keeping the error type intact where map_err would rewrite it.
Shadow the std Result with type Result<T> = Result<T, E> so every fallible signature in a module shares one error type.
Find the last occurrence of a byte pattern with rfind, getting the byte index you need for suffix slicing in one call.
Edit a Vec in fixed size batches through chunks_mut, then use chunks_exact_mut and remainder to handle the short trailing batch separately.
Shift bytes inside one slice with copy_within, which tolerates overlapping source and destination like memmove and panics only on out of range indices.
Cut a slice into halves with split_at_checked, which returns None past the end instead of panicking, so length checks fold into one match arm.
Peel a borrowed head plus the remaining slice with split_first to walk sequences without copying or index arithmetic.
Insert substrings at byte indices with String::insert_str and keep indices on char boundaries, since a multi-byte offset makes the call panic.
Run a setup function exactly once across threads with std::sync::Once and call_once, then read the side effects from shared state.
Cut iteration windows with take and skip: take grabs the first n items, skip drops them, and combining both yields offset paging over a slice.
Ask for collection capacity with try_reserve and match TryReserveError, so capacity overflow becomes a recoverable branch instead of a process abort.
Validate conversions with TryFrom: the associated Error type carries the rejection reason, and TryInto lets callers convert without naming the target type.
Collapse None and Err into type defaults with unwrap_or_default: unwrap_or takes an explicit value and unwrap_or_else builds one lazily.
Refresh a Vec in place with clone_from so an existing buffer can absorb new contents without reallocating a fresh clone.
Clone a range of a Vec onto its own end with extend_from_within, which reads the source range before growing so repeats need no temporary buffer.
Drop a Vec capacity down to its length with into_boxed_slice, then convert back with into_vec and note the capacity now equals the element count.
Preallocate Vec storage with with_capacity and reserve so pushes stay inside one allocation; printed len and capacity show exactly when growth fires.
SELECT-list aliases are visible to ORDER BY but not to WHERE or HAVING; PostgreSQL additionally lets GROUP BY refer to output column names.
Backfill large tables in chunks with UPDATE over a bounded id subquery, keeping each transaction short so locks and replication lag stay small.
A BEFORE row trigger that returns NULL silently cancels the write: the row never lands, no error is raised, and the statement simply affects fewer rows.
A CHECK expression passes whenever it evaluates to NULL, so constraints that look strict still allow missing values unless the predicate is written NULL-aware.
Pin numeric columns to valid domains with CHECK constraints: BETWEEN bounds, positive amounts, and cross-column date order — mind that NULL passes.
Enforce code formats at the database boundary with a CHECK constraint on a POSIX regex pattern, so malformed tracking codes are rejected on write.
Constrain a status column to an explicit whitelist with CHECK ... IN so invalid states are rejected at write time with a named constraint.
String concatenation with || returns NULL when any operand is NULL, so display strings built from optional columns need COALESCE per operand.
Stream query results out as CSV with COPY ... TO STDOUT: headers on demand, RFC 4180 quoting for commas and quotes, forced quotes per column.
pg_stats.correlation measures how a column's physical row order matches its logical order: near ±1 scans stay sequential, near 0 rows scatter into random I/O.
COUNT(*) counts every row while COUNT(col) skips NULLs — so they disagree on sparse columns, and COUNT(DISTINCT col) collapses repeats before skipping NULLs.
Flip a boolean feature flag in place with SET enabled = NOT enabled and RETURNING the new state, so toggling needs no read-modify-write round trip.
A foreign key can only reference columns covered by a PRIMARY KEY or UNIQUE constraint; creating one against a plain column fails with a matching-keys error.
GROUP BY treats NULL as one group key: every NULL row lands in a single bucket, even though no WHERE comparison can ever match a NULL value.