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

JavaScript Operator Types

Uploaded by

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

JavaScript Operator Types

Uploaded by

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

JavaScript Operator Types

• Here is a list of different operators you will learn in this tutorial.


• Assignment Operators
• Arithmetic Operators
• Comparison Operators
• Logical Operators
• Bitwise Operators
• String Operators
• Other Operators
JavaScript Assignment
Operators
• Assignment operators are used to assign values to variables. For
example
• const x=5;
JavaScript Arithmetic Operators

• Arithmetic operators are used to perform arithmetic calculations. For


example,
• const number = 3+5;
Arithmetic operators
• let x = 5; let y = 3;
• console.log('x + y = ', x + y); // 8
console.log('x - y = ', x - y); // 2
• console.log('x * y = ', x * y); // 15
• console.log('x / y = ', x / y); // 1.6666666666666667
• console.log('x % y = ', x % y); // 2
• console.log('++x = ', ++x); // x is now 6
• console.log('x++ = ', x++); // prints 6 and then increased to 7
• console.log('x = ', x); // 7
• console.log('--x = ', --x); // x is now 6
• console.log('x-- = ', x--); // prints 6 and then decreased to 5
• console.log('x = ', x); // 5
• console.log('x ** y =', x ** y);
JavaScript Comparison
Operators

• Comparison operators compare two values and return


a boolean value, either true or false. For example,
• const a = 3, b = 2;
• console.log(a > b); // true
// equal operator
console.log(2 == 2); // true
console.log(2 == '2'); // true

// not equal operator


console.log(3 != 2); // true
console.log('hello' != 'Hello'); // true

// strict equal operator


console.log(2 === 2); // true
console.log(2 === '2'); // false

// strict not equal operator


console.log(2 !== '2'); // true
console.log(2 !== 2); // false
JavaScript Logical Operators
Logical operators perform logical operations and return a boolean value,
either true or false. For example,

const x = 5, y = 3; (x < 6) && (y < 5); // true


Logical Operators
• // logical AND
• console.log(true && true); // true
• console.log(true && false); // false

• // logical OR
• console.log(true || false); // true

• // logical NOT
• console.log(!true); // false
JavaScript String Operators
In JavaScript, you can also use the + operator to concatenate (join)
two or more strings.

// concatenation operator
console.log('hello' + 'world');

let a = 'JavaScript';

a += ' tutorial'; // a = a + ' tutorial';


console.log(a);
Other operators

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy