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?

More than 1 year has passed since last update.

JavaScript 論理演算子の挙動

Posted at

論理演算子の挙動

論理演算子は、if文のように条件分岐に使うことができます。

&&

意味:LeftがtrueならばRightを返す。
例:

test.js
import React from "react";

export const App = () => {
  return (
    <>
      <div>
        {true && "Left is true"} 
      </div>
    </>
  );
};
//結果
Left is true

Left || Right

意味:LeftがfalseならばRightを返す。
例:

test.js
import React from "react";

export const App = () => {
  return (
    <>
      <div>
        {false || "Left is false"} 
      </div>
    </>
  );
};
//結果
Left is false

参考

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?