Today I Learned - Rocky Kev

TIL a fancy word for auto-generating objects, A Factory Function

POSTED ON:

TAGS:

So a factory function creates objects.

something like

function makeNewMage(theName) {

const newMage = {
name: theName,
magic: 100,
spell: 'fireball';
}

return newMage;

};

const JakeTheMage = makeNewMage('Jake')
const SarahtheMage = makeNewMage('Sarah')

There's no real magic to it.


Related TILs

Tagged:

TIL Indirection and Swallowing the error

Op shared a tryCatch util that is problematic.

TIL reusing variables

Do not reuse variables. Do not double define variables that represent the same thing.

TIL about semaphores

A semaphore limits access to a resource to some number of consumers. Any new requests for the resource will get stalled until later, eventually to be handled.