Techoceanhub logo

Javascript Operators

JavaScript supports various types of operators that perform different operations on variables and values. These include:

let x = 10;
let y = 3;
let sum = x + y;  // Addition
let difference = x - y;  // Subtraction
let product = x * y;  // Multiplication
let quotient = x / y;  // Division
let remainder = x % y;  // Modulus
Assignment Operators:*
let a = 5;
a += 3;  // Equivalent to: a = a + 3;

Comparison Operators:

let p = 10;
let q = 5;
console.log(p > q);  // Greater than
console.log(p < q);  // Less than
console.log(p === q);  // Equal to (strict equality)
console.log(p !== q);  // Not equal to (strict inequality)

Logical Operators:

let isLoggedIn = true;
let isAdmin = false;
console.log(isLoggedIn && isAdmin);  // Logical AND
console.log(isLoggedIn || isAdmin);  // Logical OR
console.log(!isAdmin);  // Logical NOT

Unary Operators:

let count = 5;
count++;  // Increment
console.log(count);  // Outputs: 6

Conditional (Ternary) Operator:

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

String Concatenation Operator:

let firstName = "John";
let lastName = "Doe";
let fullName = firstName + " " + lastName;  // String concatenation
console.log(fullName);  // Outputs: "John Doe"

Share:

Categories

Archives

Related Posts

Array Destructuring

Array Destructuring Array destructuring is a powerful syntax introduced in ES6 that allows you to unpack elements from an array

Read More »

Explore our Affiliated partner links

hostgator website plan

Hostgator

Best Website hosting plans & Best for 24/7 support.

hostinger webhosting plan

Hostinger

Reasonable website hosting packages for small business & 24/7 Email support

Elementor pro

Design Worpdress website quickly using Elementor Builder and AI

buy elementor website templates

Buy Elementor Website Template

Buy ready made Elementor Website Template from us & Get Free Elementor pro licence for 1 year .