LoginSignup
2
2

More than 5 years have passed since last update.

【JavaScript】while(true)でループ処理

Posted at

こんにちは。
寒いです。

僕は今まで比較演算子を使って、whileの中の判別を行っていたのですが
どうやらtrue or false で行ける模様

今まで

var condition = true ;
while(condition === true){
    console.log("loop!") ;
    condition = false ;
}

実際

var condition = true ;
while(condition){
    console.log("loop!") ;
    condition = false ;
}

因みに今回加えて試したのが、
break ; を記述することで、ループ処理を抜けることも可能。
if文を挿入して、とあるところまで来たらループ処理を抜けるみたいなことを
やるんでしょうかね。

それでは、これからも宜しくお願いいたします。

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