$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

The Executive Guide to Business Website Design: Uniting UX, SEO, and Brand Growth

Introduction A company website serves as the operational hub of its online presence. It represents the brand, delivers product and service information, answers buyer inquiries, and facilitates…

Read More

Master Guide to Business Website Planning: Essential Steps Before Development Starts

Introduction Jumping directly into wireframes, design mockups, or source code without an overarching blueprint is one of the most expensive mistakes a company can make. When organizations…

Read More

RobotOps and DevOps: Understanding the Future of Robotics Operations

Introduction to RobotOps Building a robot is hard. Operating a fleet of robots every day is even harder. For many years, robotics teams focused mainly on mechanical…

Read More

Site Reliability Engineering Explained: Tools, Practices, and Certification Paths

Introduction Software applications run modern businesses. When an application crashes, users cannot finish purchases. When a database slows down, entire workflows stop. Companies cannot afford long outages….

Read More

CMS Website Development Checklist: A Step-by-Step Guide for Business Owners

Introduction Your website is the digital headquarters of your business. It operates as your 24/7 sales representative, your primary marketing asset, and the first point of contact…

Read More

How to Choose the Right CMS for Your Business Website

Introduction A website serves as the digital engine of a modern business, but the software powering it determines how fast, secure, and adaptable that engine truly is….

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