Semicolons

Trailing semicolons

// bad
(function () {
  const name = 'Skywalker'
  return name
})()

// good
(() => {
  const name = 'Skywalker';
  return name;
}());

Leading semicolons

  • yup for IIFEs

Why? guards against the function becoming an argument when two files with IIFEs are concatenated

// good ()
;(() => {
  const name = 'Skywalker';
  return name;
}());

Read more.

results matching ""

    No results matching ""