Typescript-arithmetic-operators-examples
提供:Dev Guides
TypeScript-算術演算子の例
変数aおよびbの値がそれぞれ10および5であると仮定します。
Operator | Description | Example |
---|---|---|
PLUS (Addition) | returns the sum of the operands | a PLUS b is 15 |
- (Subtraction) | returns the difference of the values | a - b is 5 |
AST (Multiplication) | returns the product of the values | a AST b is 50 |
/(Division) | performs a division operation and returns the quotient | a/b is 2 |
% (Modulus) | performs a division and returns the remainder | a % b is 0 |
PLUSPLUS (Increment) | Increments the value of the variable by one | aPLUSPLUS is 11 |
— (Decrement) | Decrements the value of the variable by one | a-- is 9 |
例
コンパイル時に、次のJavaScriptコードが生成されます。
上記のプログラムの出力は以下のとおりです-