Math operators in JavaScript
Operators In JavaScript, you can handle arithmetic operations in JavaScript as easily as any other language. Operators are symbols, and each symbol has a specific meaning. The arithmetic operations in JavaScript are divided into two parts:
- Common normal arithmetic operations.
- Arithmetic operations on forces and fractions.
Common arithmetic operations
These operations are the common operations that everyone knows such as (addition - subtraction - multiplication - division).
- For addition we use the + sign.
- Subtraction we use the - sign.
- Multiplication we use the sign *.
- For division we use the / sign.
Examples of JavaScript Arithmetic Operations
console.log(23 + 3);
console.log(22 - 2);
console.log(22 / 2);
console.log(23 * 3);
We rendered data for all data via console and the operations in the example were:
- The first operation is the addition operation 23+3.
- The second operation is the subtraction process 22 - 2.
- The third operation is the 22/2 division operation.
- The fourth operation is 23*3 multiplication.
When we run the previous example in the browser and go to the console, we will find the results as follows:

Example 1
var firstName = "Saja";
var lastName = " Alsadig";
var name = firstName + lastName;
console.log(name);
We created two text variables, the first name and the second name, and assigned them values. Then we created a text variable name and set it to be equal to the sum of the first and second variables. And we displayed the data through the console, and when we run the code in the browser, we find its result:

Arithmetic operations on powers and fractions
This section is mainly focused on fractures and forces as they are rarely used.
- To double the power means the exponent we use **.
- To display the remainder of the division we use %.
- To increment by one we use ++.
- To decrease by one we use -- .
Examples of arithmetic operations on powers and fractions
var number = 2;
console.log(10**8);
console.log(++number);
console.log(--number);
We created a scalar variable number and its value is 2. Then we displayed the data through the console, and the display of this data was as follows.
- Doubling powers 10*8.
- Increment by 1 in ++number.
- Decrease by 1 in --number.
When we run the previous example in the browser and go to the console, we will find the results as follows:

We notice in the result that he gave us the number 100000000 because it is the result of the 10 to the 8th power, and below the 3, 2 are the result of an increase and decrease of one for the variable var number=2. There are many operations to deal with arithmetic operations shown in the following image. You can create examples from your mind and practice them by yourself.

Logical Operators JavaScript
There are many types of Boolean operators that are used in JavaScript and these operators are often used with conditions.
- The and operator is denoted as && so that it returns true if both operands are true, otherwise it will return false.
- The or operator is represented by the form || So that it returns true if one of the parameters is true, otherwise it returns false.
- The not operator is symbolized by the form ! So that it returns true if the parameter is false and returns false if the parameter is true.
The logical operator && in JavaScript
Returns true if both parameters are true, otherwise false.
var a = true;
var b = false;
if (a == true && b == false){
alert("Condition fulfilled");
}
else{
alert("Condition not met");
}
We created two variables:
- The variable a is true.
- The variable b has a value of false.
And we set a condition that if the value of the variable a is true and the value of b is false. That is, if the condition is met, print the condition is met, and if it is incorrect, print the condition is not met. And displaying the data was via a pop-up dialer, and since the condition is met, the result in the browser will be:

We conclude in && that if one is true and the other is false, the condition will not be executed.
Boolean || operator in javascript
Returns true if one of the parameters is true, otherwise it will return false.
var a = true;
var b = false;
if (a == true || b == false){
alert("Condition fulfilled");
}
else{
alert("Condition not met");
}
We created two variables:
- The variable a is true.
- The variable b has a value of false.
And we set a condition if the value of the variable a is true or the value of b is false. If the condition is true, print the condition is met, and if it is incorrect, print the condition is not met. And the data display was via a pop-up dialer, and since the condition is met, the result will be fulfilled. We conclude in || If one of them is true and the other is not, then the condition is fulfilled. I mean, we told the function that this is equal to this or this is equal to this and one of them is true.
Boolean ! in JavaScript
Returns true if the parameter is false and returns false if the parameter is true, that is, it reverses the result.
var a = true;
var b = false;
if (!a == true){
alert("Condition fulfilled");
}
else{
alert("Condition not met");
}
We conclude that if the value of the condition is true, the condition will not be fulfilled, and if it is false, it will be met.