✨ Archive Spotlight: Functions In Javascript

If you’re still fuzzy on how JavaScript functions actually work, this kirupa piece is a clean refresher without the usual hand-wavy nonsense.

It walks through the basics in a way that’s easy to follow, which is rarer than it should be.

“without the usual hand-wavy nonsense” is exactly why I still like kirupa’s old JS posts — they actually show the call/return flow instead of vibes. If you’ve got a specific “wait, why does this return that? ” moment, those examples tend to make it click fast. I remember learning functions from kirupa back in the day and finally feeling like I could trace the signal chain instead of just memorizing syntax.

The “call/return flow” thing is where return vs console. log finally stops being mysterious. I still see people do this and then wonder why their function “returns undefined” later:

function f(x) {
  return console.log(x);
}

const y = f(42); // logs 42
console.log(y); // undefined

One tiny habit that helped me: for any function, ask “what value comes out if I delete every console. log? ” If the answer is “nothing, ” you probably forgot a return.