Skip to content

Buzzingz

Unleashing the Power of Code

  • HTML
  • CSS
  • JavaScript
  • Toggle search form

JavaScript Operators

Posted on April 2, 2023April 2, 2023 By shani No Comments on JavaScript Operators

JavaScript operators are symbols used to perform operations on values or variables. There are several types of operators available in JavaScript, including assignment, arithmetic, comparison, and logical operators. By understanding these operators and how to use them, you can write more powerful and efficient JavaScript code.

Types of operators in JavaScript:

Assignment Operators

The assignment operator (=) is used to assign a value to a variable. For example:

var x = 5;

This assigns the value 5 to the variable x.

Arithmetic Operators

Arithmetic operators are used to perform mathematical operations on values. The following arithmetic operators are available in JavaScript:

  • Addition (+): Adds two values together. For example: 3 + 4.
  • Subtraction (-): Subtracts one value from another. For example: 6 - 2.
  • Multiplication (*): Multiplies two values together. For example: 5 * 7.
  • Division (/): Divides one value by another. For example: 10 / 2.
  • Modulus (%): Returns the remainder of a division operation. For example: 11 % 3 would return 2.

Comparison Operators

Comparison operators are used to compare two values and return a Boolean value (true or false). The following comparison operators are available in JavaScript:

  • Equal to (==): Compares two values for equality. For example: 3 == 3 would return true.
  • Not equal to (!=): Compares two values for inequality. For example: 3 != 4 would return true.
  • Greater than (>): Compares two values to see if the first value is greater than the second value. For example: 5 > 3 would return true.
  • Less than (<): Compares two values to see if the first value is less than the second value. For example: 2 < 7 would return true.
  • Greater than or equal to (>=): Compares two values to see if the first value is greater than or equal to the second value. For example: 6 >= 6 would return true.
  • Less than or equal to (<=): Compares two values to see if the first value is less than or equal to the second value. For example: 4 <= 5 would return true.

Logical Operators

Logical operators are used to combine two or more conditions and return a Boolean value. The following logical operators are available in JavaScript:

  • AND (&&): Returns true if both conditions are true. For example: (3 < 5) && (6 > 4) would return true.
  • OR (||): Returns true if at least one of the conditions is true. For example: (3 > 5) || (6 > 4) would return true.
  • NOT (!): Returns the opposite of a Boolean value. For example: !(3 > 5) would return true.
Javascript

Post navigation

Previous Post: JavaScript Arithmetic
Next Post: JavaScript Assignment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

JavaScript Tutorial

  • JavaScript Tutorial
  • JavaScript Where To
  • JavaScript Output
  • JavaScript Statements
  • JavaScript Syntax
  • JavaScript Comments
  • JavaScript Variables
  • JavaScript Let
  • JavaScript Const
  • JavaScript Operators
  • JavaScript Arithmetic
  • JavaScript Assignment
  • JavaScript Data Types
  • JavaScript Functions
  • JavaScript Objects
  • JavaScript Events
  • JavaScript Strings
  • JavaScript String Methods
  • JavaScript String Search
  • JavaScript Template Literals
  • JavaScript Numbers
  • JavaScript BigInt
  • JavaScript Number Methods
  • JavaScript Number Properties
  • JavaScript Arrays
  • JavaScript Array Methods
  • JavaScript Sorting Arrays
  • JavaScript Array Iteration
  • JavaScript Array Const
  • JavaScript Date Objects
  • JavaScript Date Formats
  • JavaScript Get Date Methods
  • JavaScript Set Date Methods
  • JavaScript Math Object
  • JavaScript Random
  • JavaScript Booleans
  • JavaScript Comparison and Logical Operators
  • JavaScript if, else, and else if
  • JavaScript Switch Statement
  • JavaScript For Loop
  • JavaScript For In
  • JavaScript For Of
  • JavaScript While Loop
  • JavaScript Break and Continue
  • JavaScript Iterables
  • JavaScript Sets
  • JavaScript Maps
  • JavaScript typeof
  • JavaScript Type Conversion
  • JavaScript Bitwise Operations
  • JavaScript Regular Expressions
  • JavaScript Operator Precedence
  • JavaScript Errors
  • JavaScript Scope
  • JavaScript Hoisting: Understanding the Basics
  • JavaScript Use Strict: The Importance of Strict Mode in JavaScript
  • The JavaScript this Keyword
  • JavaScript Arrow Function: A Concise and Comprehensive Guide
  • JavaScript Classes: Understanding the Basics
  • JavaScript Modules
  • JavaScript JSON
  • JavaScript Debugging
  • JavaScript Style Guide
  • JavaScript Best Practices
  • JavaScript Common Mistakes: How to Avoid Them
  • JavaScript Performance: Techniques for Improving Your Code
  • About Us
  • Contact Us
  • Privacy Policy
  • Terms & Conditions

Copyright © 2023 Buzzingz.

Powered by PressBook WordPress theme