4
Help us understand the problem. What are the problem?

posted at

[備忘録]javascriptで配列のチェックにeveryを使う時は注意

everyは配列要素が0のとき必ずtrueを返すため、知らずに使うと意図しない動作を引き起こす可能性があるので注意が必要です。

image.png

MDNに注意書きはしてあるが、一致するものがないんだからfalseじゃないか?と思う。。。

image.png
参考:https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/every

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Sign upLogin
4
Help us understand the problem. What are the problem?