Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
4 views

JavaScript Operators

Uploaded by

budi utomo
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

JavaScript Operators

Uploaded by

budi utomo
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Day 02: JavaScript Operator

Types of operator in JS

1. What is Operator
2. Arithmetic Operators
3. Comparison or Relational Operators
4. Logical Operators
5. Assignment Operators
6. Conditional Operators
JavaScript Operator
What is operator? Types of operator in JS
Operator is the symbol which perform a operation 1. Arithmetic Operators
Operator take action on operand or set of operand 2. Comparison or Logical Operators
3. Logical Operators
4. Assignment Operators
5. Conditional Operators
JavaScript Arithmetic Operator
1) Arithmetic Operators
These operator are used as arithmetic operator
Name Symbol
• Addition +
• Subtraction -
• Division /
• Multiplication *
• Modulus %
• Increment ++
• Decrement --
JavaScript Comparison Operators
2) Comparison Operators
To compare two values, we used comparison operator. Or to find a relation between two values, we also used
such operator: That are:
Name Operator
• To check quality ==
• To check not equality !=
• Greater than >
• Greater than or equal to >=
• Less than <
• Less than or equal to <=
JavaScript Logical Operators
3) Logical Operators Example:
It work with compound expression a = 10
It return Boolean value, true or false b = 30
There are three operator used as logical operator c = 23
Name Operator d = 23
• AND && (a == b) && (c > d)
• OR || (a == b) || (c > d)
• NOT ! !(a>b)
JavaScript Assignment Operators
4) Assignment Operator
“=” is the assignment operator. That is used to assign a value to variable
var a = 23;
Arithmetic assignment operator
• Addition Assignment operator +=
• Subtraction Assignment operator -=
• Multiplication Assignment operator *=
• Division Assignment operator /=
• Modulus Assignment operator %=
JavaScript Conditional Operators
5) Conditional OR Ternary Operators
It is called a ternary operator which take 3 operand
It take a condition and two statement. If condition is true, it execute first statement, otherwise 2 nd.
Syntax:
Condition ? Print X if condition true : Print Y if condition is false
Example:
a = 20;
b = 30;
res = (a<b)? “True" : “False";
document.write(res);

You might also like