.end() and .addBack(): The Chaining Verbs Nobody Learned
jQuery keeps a stack of every traversal you make. .end() pops it, .addBack() merges it - and suddenly one chain does what used to take three variables.
Software Engineer
I build web applications and share what I learn along the way.
Step-by-step programming tutorials on PHP, JavaScript, Laravel, WordPress and more.
jQuery keeps a stack of every traversal you make. .end() pops it, .addBack() merges it - and suddenly one chain does what used to take three variables.
Chainability, per-element state, options with defaults, re-init safety - the four requirements of a proper $.fn plugin, in one compact pattern you can reuse forever.
No cURL, no Guzzle, no problem: stream contexts give file_get_contents methods, headers, bodies, timeouts - plus a magic variable that captures response headers.
Caching computed data per object with static arrays pins those objects in memory forever - a leak with a cache's haircut. PHP 8's WeakMap caches without owning.
Keyed destructuring, foreach unpacking, swaps, nested extraction - the [$a, $b] syntax has quietly become one of PHP's best readability tools.
Every date in a month, every Monday for a year, billing cycles between two dates - DatePeriod iterates ranges natively, immutably and off-by-one-free.
Currency placement, month names, ordinal suffixes, "1.234,56" vs "1,234.56" - the intl extension knows every locale's rules, and most PHP developers never call it.
PHP 8.1 turned functions into values you can pass, store and compose - ending the string-callable era of 'array_map("strtoupper", ...)' and its silent refactoring bugs.
Every chat box and comment field ships JS that measures scrollHeight to grow the textarea. One CSS property now does it natively - with a progressive-enhancement story for the rest.
Half your dark-mode CSS is pairs of rules flipping the same property. light-dark() collapses each pair into one line - and color-scheme unlocks free dark UI from the browser itself.
Elements appearing via display changes always snapped into place because there was no "before" state to transition from. Two new pieces of CSS fix entry AND exit animations.
animation-timeline: scroll() binds any CSS animation to scroll position - reading progress bars, parallax, scroll reveals - running off the main thread entirely.