JavaScript : Arithmetic

Arithmetic operators in JavaScript are used to perform mathematical calculations on numeric operands. JavaScript supports standard arithmetic operators for addition, subtraction, multiplication, division, and more. Let's explore these arithmetic operators:

1. Addition (+):


The addition operator ( + ) adds two numeric values or concatenates two strings.


let sum = 5 + 3;       // Result: 8 (numeric addition)
let fullName = "John" + " " + "Doe";  // Result: "John Doe" (string concatenation)

 

2. Subtraction (-):


The subtraction operator ( - ) subtracts the second operand from the first.


let difference = 10 - 5;  // Result: 5
 

3. Multiplication (*):


The multiplication operator ( * ) multiplies two numeric values.


let product = 3 * 4;  // Result: 12
 

4. Division (/):


The division operator (`/`) divides the first operand by the second.


let quotient = 12 / 3;  // Result: 4
 

5. Modulus (%):


The modulus operator (`%`) returns the remainder of the division operation.


let remainder = 10 % 3;  // Result: 1
 

6. Exponentiation (**):


The exponentiation operator ( ** ) raises the first operand to the power of the second operand.


let result = 2 ** 3;  // Result: 8 (2 raised to the power of 3)
 

Example Usage:

Here's an example demonstrating the use of arithmetic operators in JavaScript:


let a = 10;
let b = 5;

let sum = a + b;         // Result: 15
let difference = a - b;  // Result: 5
let product = a * b;     // Result: 50
let quotient = a / b;    // Result: 2
let remainder = a % b;   // Result: 0

console.log("Sum:", sum);
console.log("Difference:", difference);
console.log("Product:", product);
console.log("Quotient:", quotient);
console.log("Remainder:", remainder);

 

Conclusion:


Arithmetic operators are fundamental in JavaScript for performing mathematical calculations and manipulating numeric values. Understanding how to use these operators allows you to perform various arithmetic tasks in your JavaScript programs. Whether you're adding numbers, concatenating strings, or finding remainders, arithmetic operators are essential tools for working with numerical data.

AI car modification · buy quality backlinks · guest post service · link building service · link building service · buy backlinks · SEO, GEO, AEO, AIO and LLMO · Bedeutung von Backlinks für Google · winandoffice · aiswapface photo face swap · dofollow backlinks · link building service · guest post service · quality backlinks · guest post service · dofollow backlinks · link building service · dofollow backlinks · buy backlinks · buy quality backlinks · dofollow backlinks · dofollow backlinks · link building service · hacklink satın al · Contextual backlinks: judge the paragraph and destination together · hacklink · hacklink satın al · hacklink panel satın al · jojobet · hacklink satın al · jojobet · jojobet · jojobet · jojobet · jojobet · jojobet · jojobet · jojobet · jojobet · jojobet · jojobet giriş · jojobet güncel · jojobet · jojobet · jojobet · jojobet