📜  TypeScript-决策

📅  最后修改于: 2020-10-19 03:50:14             🧑  作者: Mango


决策结构要求程序员指定一个或多个要由程序评估或测试的条件,以及确定条件为真的情况下要执行的一条或多条语句,以及选择确定条件时要执行的其他语句。条件确定为假。

下面显示的是大多数编程语言中常见的典型决策结构的一般形式-

做决定

决策构造在执行指令之前评估条件。 TypeScript中的决策构造分类如下-

S.No. Statement & Description
1. if statement

An ‘if’ statement consists of a Boolean expression followed by one or more statements.

2. if…else statement

An ‘if’ statement can be followed by an optional ‘else’ statement, which executes when the Boolean expression is false.

3. else…if and nested if statements

You can use one ‘if’ or ‘else if’ statement inside another ‘if’ or ‘else if’ statement(s).

4. switch statement

A ‘switch’ statement allows a variable to be tested against a list of values.