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?

[Javascript][python]VBAのIIF関数みたいなやつ

0
Last updated at Posted at 2026-02-19

Javascript

  • VBAの IIf(条件, 真の値, 偽の値) に相当するのは三項演算子です。
//三項演算子
// VBA: IIf(x > 0, "正", "負")
const result = x > 0 ? "" : "";
  • 論理OR演算子(デフォルト値に便利)
//論理OR演算子
const result = value || "デフォルト値";
  • Null合体演算子(null/undefinedのみ対象)
const result = value ?? "デフォルト値";

python

  • 三項演算子
# VBA: IIf(x > 0, "正", "負")
result = "" if x > 0 else ""

※Pythonは 条件 ? 真 : 偽 ではなく、真の値 if 条件 else 偽の値 という語順になるのが特徴です。

  • 論理OR演算子
result = value or "デフォルト値"
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?