Hello everyone, welcome to **nkcoderz.com**. In this article we will going to discuss about Basic Operators In JavaScript.

JavaScript is a powerful programming language that is widely used to create interactive and dynamic websites. One of the key features of JavaScript is its ability to perform operations on data using operators.

In this article, we will explore the basic operators in JavaScript and how they are used.

Table of Contents

## Basic Operators In JavaScript

The basic operators in JavaScript include arithmetic operators, assignment operators, comparison operators, and logical operators. Understanding these operators is essential for developing efficient and effective code in JavaScript.

The first type of operator in JavaScript is the arithmetic operator. Arithmetic operators are used to perform mathematical operations such as addition, subtraction, multiplication, and division. These operators include + (addition), – (subtraction), * (multiplication), / (division), % (modulus), and ++ (increment).

For example, the following code uses the addition operator to add two numbers:

## Code For Addition Operator

```
var a = 5;
var b = 10;
var c = a + b;
```

## Output

c is equal to 15

The next type of operator in JavaScript is the assignment operator. Assignment operators are used to assign a value to a variable.

The most basic assignment operator is the equal sign (=), which assigns a value to a variable. For example, the following code assigns the value 5 to the variable “a”:

## Code For Assignment Operator

```
var a = 5;
```

JavaScript also has a set of comparison operators that are used to compare values. These operators include == (equal to), != (not equal to), > (greater than), < (less than), >= (greater than or equal to), and <= (less than or equal to).

For example, the following code uses the greater than operator to compare two numbers:

## Code For Comparison Operator

```
var a = 5;
var b = 10;
if (a > b) {
console.log("a is greater than b");
} else {
console.log("a is not greater than b");
}
```

## Output

`a is not greater than b`

JavaScript also has a set of logical operators that are used to perform logical operations such as AND, OR, and NOT.

These operators include && (AND), || (OR), and ! (NOT). For example, the following code uses the AND operator to check if two conditions are true:

## Code For Logical Operator

```
var a = 5;
var b = 10;
if (a > 0 && b > 0) {
console.log("a and b are greater than 0");
}
```

## Output

`a and b are greater than 0`

In conclusion, JavaScript is a powerful programming language that allows developers to perform operations on data using operators.

If you liked this post, then please share this with your friends and make sure to bookmark this website for more awesome content.