LoginSignup
0
0

More than 5 years have passed since last update.

ヨーダ記法

Last updated at Posted at 2017-10-24

eslintrcの設定項目にyoda(Yoda condition)という項目があり、
知らなくて何これと思ったので調べました。

js

if ("red" === color) {
    // ...
}

「赤は色」という記述がヨーダ風(目的語-主語-動詞)とのことで、
この記法には「条件式のつもりで代入文を書いてしまう」ような記述ミスを回避する利点がある。
可読性の欠如が上記利点を上回っているという批判もあるようです。

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