profileRyan KesPGP keyI build stuffEmailGithubTwitterLast.fmMastodonMatrix

JavaScript declaration notation

There is a shorter way to declare functions:

function square(x) {
  return x * x
}

console.log(square(5))

Function declarations are not part of the regular top-to-bottom flow on control. They are conceptually moved to the top of their scope and can be used by all the code in that scope.

console.log("The future says:", future())

function future() {
  return "Where are my flying cars?"
}