Loading
undefined

Returning undefined (JavaScript)

Because sometimes things aren’t so obvious – All these functions return undefined.

const funcA = () => {};

const funcB = () => {
  return;
};

const funcC = () => {
  return undefined;
};

console.log("funcA returns", funcA()); // funcA returns undefined
console.log("funcB returns", funcB()); // funcB returns undefined
console.log("funcC returns", funcC()); // funcC returns undefined

See example online at https://codesandbox.io/s/returning-undefined-x6wxh


Did you find it interesting? Follow me on Twitter.

Leave a Reply

Your email address will not be published. Required fields are marked *