JavaScript Operators

Level : Beginner
Mentor: Shailendra Chauhan
Duration : 00:01:00

Arithmetic Operators:

Arithmetic operators perform mathematical operations on numbers.

Example:

let x = 10;
let y = 5;
let sum = x + y;
console.log("Sum:", sum); // Output: Sum: 15

Assignment Operators:

Assignment operators are used to assign values to variables.

Example:

let a = 10;
let b = 5;
a += b;
console.log("a:", a); // Output: a: 15

Comparison Operators:

Comparison operators compare two values and return a Boolean result.

Example:

let num1 = 10;
let num2 = 5;
let isEqual = num1 === num2;
console.log("isEqual:", isEqual); // Output: isEqual: false 

String Operators:

String operators concatenate (join) strings or extract substrings.

Example:

let str1 = "Hello, ";
let str2 = "world!";
let greeting = str1 + str2;
console.log(greeting); // Output: Hello, world!

Logical Operators:

Logical operators perform logical operations on Boolean values.

Example:

let isTrue = true;
let isFalse = false;
let result = isTrue && isFalse;
console.log("result:", result); // Output: result: false

Bitwise Operators:

Bitwise operators manipulate the individual bits of numbers.

Example:

let num1 = 5; // Binary: 101
let num2 = 3; // Binary: 011
let result = num1 & num2; // Binary: 001 (Decimal: 1)
console.log("result:", result); // Output: result: 1

Ternary Operators:

Ternary operators provide a concise way to write conditional expressions.

Example:

let age = 20;
let status = age >= 18 ? "Adult" : "Minor";
console.log("status:", status); // Output: status: Adult

Type Operators:

Type operators determine the type of a value or check instance relationships.

Example:

let value = "Hello";
let type = typeof value;
console.log("type:", type); // Output: type: string
Self-paced Membership
  • 24+ Video Courses
  • 825+ Hands-On Labs
  • 400+ Quick Notes
  • 125+ Skill Tests
  • 10+ Interview Q&A Courses
  • 10+ Real-world Projects
  • Career Coaching Sessions
  • Email Support
Upto 60% OFF
Know More
Still have some questions? Let's discuss.
CONTACT US
Accept cookies & close this