Perform Mathematical Operations In JavaScript
Arithmetic operators perform addition, subtraction, multiplication, division, exponentiation, floor division and modulus operations.
JavaScript arithmetic operators allow for numerical calculations and manipulation.
An operand is the object of a mathematical operation. Operands for the arithmetic operators can be integers or real numbers.
Arithmetic Operators For JavaScript
JavaScript Arithmetic Operators
Name | Description | Example |
---|---|---|
+ | Addition Or Sum | num1 + num2 |
– | Subtraction Or Difference | num1 – num2 |
* | Multiplication Or Product | num1 * num2 |
/ | Division Or Quotient | num1 / num2 |
% | Modulus Or Division Remainder | num1 % num2 |
** | Exponentiation Or Raising Power | num1 ** num2 |
Math.floor() | Floor Division | Math.floor(num1 / num2) |
Name | Description | Example |
JavaScript Arithmetic Operators Snippet
// OjamboShop.com Learning JavaScript Arithmetic Operators Tutorial // let num1 = 5; let num2 = 3; let num_add = num1 + num2; let num_sub = num1 - num2; let num_mul = num1 * num2; let num_div = num1 / num2; let num_mod = num1 % num2; let num_exp = num1 ** num2; let num_flo = Math.floor(num1 / num); console.log(num_add); // Console Displays 8 console.log(num_sub); // Console Displays 2 console.log(num_mul); // Console Displays 15 console.log(num_div); // Console Displays 1.66 console.log(num_mod); // Console Displays 2 console.log(num_exp); // Console Displays 125 console.log(num_flo); // Console Displays 1
Usage
You can use any IDE or text editor and the web browser to compile and execute JavaScript code. For this tutorial, the OjamboShop.com Learning JavaScript Course Web IDE can used to input and compile JavaScript code for the arithmetic operators.
Open Source
JavaScript follows the ECMAScript standard and is licensed under the W3C Software License by web browser vendors and runtime environment vendors. This allows commercial use, modification, distribution, and allows making derivatives proprietary.
Learn Programming Courses:
Courses are optimized for your web browser on any device.
Limited Time Offer:
OjamboShop.com is offering 20% off coupon code SCHOOL for Learning JavaScript Course or Learning Python Course or for Learning PHP Course until End Day 2024.
Learn Programming Ebooks:
Ebooks can be downloaded to your reader of choice.
Conclusion:
JavaScript makes it easy to use the arithmetic operators. Use arithmetic operators for numerical calculations and manipulations.
Take this opportunity to learn the JavaScript, Python or PHP programming language by making a one-time purchase at Learning JavaScript Course or Learning Python Course or Learning PHP Course. A web browser is the only thing needed to learn JavaScript, JavaScript or PHP in 2024 at your leisure. All the developer tools are provided right in your web browser.
If you prefer to download ebook versions for your reader then you may purchase at Learning Python Ebook or Learning PHP Ebook
For custom websites, app development and one-on-one tutorials, go to OjamboServices.com.
References:
- Learning JavaScript Course on OjamboShop.com
- Learning Python Course on OjamboShop.com
- Learning PHP Course on OjamboShop.com
- Learning Python Ebook on Amazon
- Learning PHP Ebook on Amazon
- OjamboServices.com For Custom Websites, Applications & Tutorials