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?

React勉強メモ

Posted at

React条件分岐 Trueだったら ? の後のコードを実行 Falseだったら : の後のコードを実行
例: {expression.length > 0 ? expression.join("") : count} みたいな

join(" ")は配列の要素を空白で区切って結合する関数

==========================================================
型のエラーが出たら、とにかく明示!!

============================================================
この書き方は丸暗記でもいいかも
const lastElement = expression[expression.length - 1];

if (!["+", "-", "*", "/"].includes(String(lastElement))) {
setExpression([...expression, operator]);
} else {
console.log("すでに演算子が入力されています");
}

要はexpressionのラストに記号が含まれて"いない"なら、expressionに operatorを追加して
setExpressionに反映って流れ。 

結論 →→ ! は 「〇〇じゃなかったら」 
!true 「trueじゃなかったら」
!false 「falseじゃなかったら」

要勉強 

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?