$100 Website Offer

Get your personal website + domain for just $100.

Limited Time Offer!

Claim Your Website Now

JavaScript Operators

JavaScript supports a variety of operators, which are symbols used to perform operations on variables and values. Here’s an overview of some common types of operators in JavaScript:

1. Arithmetic Operators:

let x = 10;
let y = 5;

console.log(x + y); // Addition: 15
console.log(x - y); // Subtraction: 5
console.log(x * y); // Multiplication: 50
console.log(x / y); // Division: 2
console.log(x % y); // Modulus: 0 (remainder after division)
console.log(x ** y); // Exponentiation: 100000

2. Assignment Operators:

let a = 10;

a += 5; // Equivalent to a = a + 5
console.log(a); // Output: 15

a -= 3; // Equivalent to a = a - 3
console.log(a); // Output: 12

a *= 2; // Equivalent to a = a * 2
console.log(a); // Output: 24

a /= 4; // Equivalent to a = a / 4
console.log(a); // Output: 6

3. Comparison Operators:

let p = 5;
let q = "5";

console.log(p == q); // Equality (loose equality): true
console.log(p === q); // Strict equality (checks value and type): false
console.log(p != q); // Inequality (loose inequality): false
console.log(p !== q); // Strict inequality: true

console.log(x > y); // Greater than: true
console.log(x < y); // Less than: false
console.log(x >= y); // Greater than or equal to: true
console.log(x <= y); // Less than or equal to: false

4. Logical Operators:

let isTrue = true;
let isFalse = false;

console.log(isTrue && isFalse); // Logical AND: false
console.log(isTrue || isFalse); // Logical OR: true
console.log(!isTrue); // Logical NOT: false

5. Unary Operators:

let num = 5;

console.log(-num); // Unary negation: -5
console.log(+num); // Unary plus: 5 (no effect)
console.log(++num); // Increment: 6
console.log(--num); // Decrement: 5

6. Conditional (Ternary) Operator:

let age = 20;
let eligibility = (age >= 18) ? "Eligible" : "Not eligible";
console.log(eligibility); // Output: "Eligible"

These are some of the fundamental operators in JavaScript. They allow you to perform a wide range of operations, from basic arithmetic to complex conditional logic. Understanding and using these operators is essential for writing effective and concise JavaScript code.

Related Posts

Smarter Medical Travel Planning with MyMedicPlus Healthcare Assistance

Navigating the international medical landscape can often feel like an overwhelming, uphill battle for individuals seeking specialized clinical treatment. Fortunately, the emergence of advanced digital health ecosystems…

Read More

Smarter Hospital Selection With MyHospitalNow and Cost Transparency

Introduction Imagine sitting at your kitchen table late at night, staring at a medical diagnosis or a recommendation for an upcoming surgery. Your mind immediately floods with…

Read More

Accelerating Your Engineering Impact with the Certified FinOps Professional Certification

Introduction In the rapidly evolving landscape of cloud-native infrastructure, managing cloud expenditure has become as critical as maintaining system uptime. The Certified FinOps Professional certification offers a…

Read More

Step-by-Step Tutorial: Reset WordPress Admin Password Using WP-CLI Commands

What is WP-CLI? WP-CLI is the command-line tool for managing WordPress without opening the browser. You can manage users, plugins, themes, database, cache, posts, and even reset…

Read More

Understanding the Value of the Certified FinOps Manager for DevOps Professionals

Introduction In the current landscape of cloud-native infrastructure, managing costs has transitioned from a back-office accounting task to a core engineering responsibility. The Certified FinOps Manager credential…

Read More

Best Travel Forum to Ask Questions & Plan Trips | HolidayLandmark

The Shift from Search Bars to Community Chats Imagine planning a two-week dream vacation to Tokyo. You type your query into a traditional search engine, and you…

Read More
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x