0% found this document useful (0 votes)
4 views

Operators in java

About the 4 operators in java script

Uploaded by

zahra14342
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Operators in java

About the 4 operators in java script

Uploaded by

zahra14342
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

JavaScript Operators

1. Arithmetic Operators:

Arithmetic operators allow you to perform basic mathematical operations like addition, subtraction,
multiplication, and more.

+ (Addition): Adds two numbers or concatenates strings. Example: 5 + 3 results in 8.


- (Subtraction): Subtracts the right operand from the left. Example: 10 - 4 results in 6.
* (Multiplication): Multiplies two values. Example: 7 * 2 results in 14.
/ (Division): Divides the left operand by the right. Example: 20 / 5 results in 4.
% (Modulus): Returns the remainder of a division. Example: 10 % 3 results in 1.

2. Logical Operators

Logical operators are used to evaluate conditions, typically involving Boolean value (true or false), and
return true or false based on the logic.

&& (AND): Returns true if both conditions are true. If either condition is false, the result is false.
|| (OR): Returns true if at least one condition is true.
! (NOT): Reverses the Boolean value of a condition.

3. Comparison Operators

Comparison operators compare two values and return a Boolean value (true or false). They are crucial
for conditional statements and loops.

== (Equal): Checks if two values are equal, ignoring type. Example: 5 == '5' results in true.
!= (Not Equal): Checks if two values are not equal, ignoring type. Example: 5 != '6' results in true.
> (Greater Than): Returns true if the left operand is greater than
Example: 7 > 5 results in true.
the right.
< (Less Than): Returns true if the left operand is less than the right. Example: 4 < 6 results in true.
>= (Greater Than or Equal): Returns true if the left operand is
Example: 5 >= 5 results in true.
greater than or equal to the right.
<= (Less Than or Equal): Returns true if the left operand is less
Example: 3 <= 4 results in true.
than or equal to the right.

4. String Operators

Strings are a set of characters. String operators are used to Concatenate (combine) or manipulate
strings. They work primarily with the + operator.

+ (Concatenation): Combines two or more strings Example: "Hello" + " World" results in "Hello
into one. World".

You might also like