LoginSignup
0
0

More than 3 years have passed since last update.

演算【JavaScriptから始めるプログラミング】

Last updated at Posted at 2020-01-15

演算

JavaScriptでは、演算を行うことができます。
また、演算を行う時に使用する「+」や「-」などの記号のことを演算子と言います。

四則演算

まずは、基本的な演算である四則演算です。

加算

「+」の演算子を使用する。

addition.js
console.log(100 + 200); //300

減算

「-」の演算子を使用する。

subtraction.js
console.log(200 - 80); //120

乗算

「*」の演算子を使用する。

multiplication.js
console.log(100 * 3); //300

除算

「/」の演算子を使用する。

division.js
console.log(400 / 5); //80

その他の演算

四則演算以外にも余りを求める演算子や、べき乗を求める演算子などがあります。

除算を行った時の剰余

「%」の演算子を使用する。

surplus.js
console.log(402 % 5); //2

べき乗

「**」の演算子を使用する。

exponentiation.js
console.log(2 ** 3); //8
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