Skip to content

Function

Easy — everyone uses thisGeneral Dev

ELI5 — The Vibe Check

A function is a reusable recipe. You write the steps once, give it a name, and call it whenever you need those steps done. Instead of writing 'mix, bake, cool' every time, you just say 'makeCake()' and it does all of that for you.

Real Talk

A function is a named, reusable block of code that performs a specific task. It can accept inputs (parameters), execute logic, and return a result (return value). Functions are the primary unit of code reuse and abstraction in most languages.

Show Me The Code

function greet(name: string): string {
  return `Hello, ${name}!`;
}

console.log(greet("Alice")); // "Hello, Alice!"

When You'll Hear This

"Extract that logic into a function." / "This function is doing too many things — split it up."

Made with passive-aggressive love by manoga.digital. Powered by Claude.