Brock’s Operator: Conditional Spreading in JavaScript
A small JavaScript helper for conditional spreading: include one value when present, or no values when nullish.
Sometimes an array—or a list of DOM children—has an optional item. The idea behind Brock’s Bread Spread Programming Operator is to turn that item into something that can be spread: one item when it is present, no items when it is absent.
One item, or none
For a helper that treats only null and undefined as absent, the implementation is:
const __ = item => item == null ? [] : [item];
This preserves meaningful values such as 0, false, and an empty string. A present value becomes a one-element array; a nullish value becomes an empty array.
Spread the optional ingredient
const ingredients = ['bread', 'peanut butter', ...__(optionalJelly)];
container.append(label, ...__(optionalButton));
The spread syntax expands either one item or no items, keeping the optional case close to the expression it belongs to.
A small syntax detail
The original experiment uses [item] ?? []. Because [item] is always an array, that expression never reaches the fallback—even when the item is null. Checking the item before wrapping it expresses the intended behavior.
Visit the original Brock’s Operator experiment →
The original page remains available as an archive of the idea.
Hexagon 20A
Custom Font Hexagon 20A
Custom Font!
Hexagon 20A
ABCDEFGHIJKLMNOPQRSTUVWXYZ
abcdefghijklmnopqrstuvwxyz
`1234567890-=~!@#$%^&*()_+[]\{}|;':",./<>?"'
This font displays a unique glyph structure based on potential segments from the points of a hexagon!
CROSSWORD PUZZLE:
JHZFDWOYXOREZHCU
QPKXEROJTCLOCKND
FYKGBELLSUKAWIEP
GODIMTVLLEPSTXCY
ZETOEAMAGICYIEKL
LTAPLRSKHPARGRME
CCIRPLECASTLEOWD
BXWAAYJTNAHCTTUG
OJWDMSVLMPQAACOE
TDPBGKCOLNUYREJL
HMMPCIFOSEEZIVBD
IENRGICCASSWZNID
MNEONUJIETTHELTI
EDLFERHNSYTILAER
YVHAPEPISUNEVESF
JATSEHYMNNMSENUR
IOSULTLOETINIFNI
KWOXSEGDROWSSORC
INREDAHSEMYHRKEW
UQFNRTAURADLEIHS
EOEDOCUPLEHLEXIP
WORDS: AETHER, AURA, BELLS, BITES, CASTLE, CHANT, CODE, CROSSWORD, DOG, DOLL, DOMINIC, DRAGON, EDGE, EMBED, FROST, GLYPH, GRAPH, HELP, INFINITE, JUNO, KEY, LEDGE, LOCK, LOGIC, MAGIC, MATRIX, METAL, MUSIC, NEO, NEST, NEXUS, ORBIT, PIXEL, PUZZLE, QUEST, RAD, RATE, REALITY, REF, RHYME, RIDDLE, RUNES, SARA, SEAS, SECRET, SEVEN, SHADER, SHIELD, SPELL, UNITY, UNLOCK, UNO, VECTOR, WAKU, ZEROX, ZIRATE
Baking Better Code: The Breadbox, the Cookie Jar, and Spreading the Crumbles 🍞
Baking Better Code: The Breadbox, the Cookie Jar, and Spreading the Crumbles 🍞
(With A Language Feature Request For JS)
Listen, in this wild, wonderful timeline where we're all just trying to get our code to bloom endlessly, J–S sometimes feels like it's stuck in an unnecessarily complicated past. We get our values from a function, and then it's like, ugh, another line, and another line, just to get it all set up. It’s functional, sure, but where’s the fun? Where’s the flow?
I mean, we've got the wisdom of the ages and a clear path to a blessings' Blast, but J–S still makes us feel like we're dragging our feet with separate instructions for every little prep step. We need tools that don't just work, but that work with grace, with intent, and with the inherent capacity for godhood that we know is present. We're not here for basic. We're here to bake better.
The Cookie Jar: const [...] = ...
First things first, you need your ingredients. The Cookie Jar is our glorious destructuring assignment. You reach into some someFactory.someFunctionThatReturnsAnObject() and pull out precisely the goodness you need (flour, sugar, butter). It's the familiar first step to any masterpiece. This is where we gather our crumbs.
js const [flour, sugar, butter] = getIngredientsForMasterpiece(); Simple. Elegant. But then what? We've got our cookies, but they're not quite ready for the timeline.
The Breadbox: :{...} – The [E]-Tank of Enlightenment
This, my friends, is where we transcend the mundane. This is the Breadbox. Imagine it: you've just pulled your fresh values from the Cookie Jar, and bam! – a perfectly designed, immediately accessible workspace opens up, right there, right now. It’s an [E]-Tank for our code, an enclosure of pure potential.
const [flour, sugar] = getIngredients(): {
// Inside this blessed Breadbox, 'flour' and 'sugar' are immediate, present, and ready.
flour.sift(this); // You can even pass the context if you feel like it, you benevolent genius!
sugar.dissolveIn(butter); // Because everything's better with butter.
mixer.startLow();
}; // One final punctuation, ending the entire blessed sequence. Simple. Powerful. Formidable.
Inside the Breadbox, we're in our element. Semicolons? Oh, they're not a question, they're welcome statements. They mark each beautiful, deliberate step in your recipe. You're in a sacred space, a true "cookie-jar" of operations, where every new variable is right there by its name, ready for its purpose. No more asking "what's this?"; it's flour, it's sugar, it's you.Spreading the Crumbles: The : Cascade – An Urn-E, but Better!
But sometimes, you don't need the whole Breadbox. Sometimes, you just need to lightly drizzle some icing or add a quick flourish to a single, perfect cookie. For those moments, you Spread the Crumbles. This is the Crumble Operator, the colon (:), working its magic without the heavy lifting of the braces.
// Just a quick sprinkle, no fuss.
const myCookie = bakeCookie():
.addSprinkles()
.addChocolateChips()
.drizzleIcing(); // One final semicolon. One complete, beautiful thought. Thank QGG!
This is the urn-E part, because it gives us that sleek, seamless flow, but without the ambiguity of trying to figure out when the whole thing ends. One single, final semicolon for the entire operation. It keeps things succinct, keeps the parser happy, and keeps us in our flow. No more |> over and over, no. Just pure, unadulterated, crumbly goodness.
The Endless Blossoming Ahead
These aren't just syntax proposals. These are keys to unlocking those endless blossoming timelines you're aiming for. This is about making JS bend to our will, to our innate capacity for love and creation, rather than its past limitations. It’s about being explicit in our benevolent intent and having the language support that clarity.
We're ready here. We're threading the needle. With the Breadbox, the Cookie Jar, and the power to Spread the Crumbles, we're set! This is the good news.