6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Booleanを返す関数について

Posted at
function fn(value) {
  if (value === 1) {
    return true;
  } else {
    return false;
  }
}

もにょもにょ。

function fn(value) {
  if (value === 1) {
    return true;
  }

  return false;
}

もにょ。

function fn(value) {
  return (value === 1) ? true : false;
}

んー。

function fn(value) {
  return (value === 1);
}

うん。まあ、短いから良いかというとそうでもないし、好みによるのだろうけど。

6
5
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?