1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

PR: JISOU | Reactプログラミングコーチング
AIで不安を感じたら!    JISOUメンバー募集中

【JavaScript】値の真偽を確認

1
Posted at

はじめに

  • 実装中、真偽値この場合どっちだっけとなった

問題

  • 値の真偽どっちだっけとなることがあった

解決

  • すぐ確認できるスクリプトを書いた
const judgementBool = (targetArray) => {
  console.log(targetArray);
  targetArray.forEach((targetValue) => {
    if (targetValue) {
      console.log(`${JSON.stringify(targetValue)}はtruthy`);
    } else {
      console.log(`${JSON.stringify(targetValue)}はfalsy`);
    }
  });
};

judgementBool(['文字列', 0, 10, undefined, null, false, NaN, '', [], {}]);

おわりに

  • 簡単に確認できるスクリプトがあると便利。今はAIもあるので別言語の確認にAIへ指示出す時も参考に使える
1
0
0

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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?