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

= と === の違い、知らないとヤバい!

Last updated at Posted at 2025-02-22

プログラムはエラーも出ないのに、なぜか YES しか出力されない…。そんな不思議なバグにハマった僕。原因は 比較演算子のミス だった!
代入と比較の違い

if (line = "paiza") { // バグる原因

=代入 であり、比較じゃない。
正しくは ===(厳密比較) を使う!

if (line === "paiza") { // これが正解!

知らないと、意図しないバグの 温床 に…。

僕の失敗談と解決話

0
0
1

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