JavaScript Operators, Operators in JavaScript, JavaScript, Electro4u.net

06 Sep 2023 Balmiki Mandal 0 JavaScript

Operators in JavaScript

JavaScript is a very powerful programming language, and it offers a variety of operators to perform specific tasks. These operators are used to do operations on values and variables. In JavaScript, there are 8 types of operators: arithmetic, assignment, comparison, logical, bitwise, string, unary, and ternary.

Arithmetic Operators

Arithmetic operators are used to perform basic mathematical calculations. The most common arithmetic operators are addition (+), subtraction (-), multiplication (*), division (/), and modulus (%).

Assignment Operators

Assignment operators are used to assign values to variables. The most common assignment operator is the equal sign (=). Other assignment operators include +=, -=, *=, /=, %=, and **=.

Comparison Operators

Comparison operators are used to compare two values and determine if they are equal or not. These operators include == (equal), != (not equal), === (strict equal) and !== (strict not equal).

Logical Operators

Logical operators are used to combine multiple conditions into a single expression. These operators include && (and), || (or), and ! (not).

Bitwise Operators

Bitwise operators are used to manipulate individual bits within an integer value. Consequently, these operators are usually used for low-level operations, such as memory management. The most common bitwise operators are & (and), | (or), ^ (xor), ~ (not), << (left shift), and >> (right shift).

String Operators

String operators are used to manipulate strings. These operators include + (concatenation), += (appending), and \\ (escaping).

Unary Operators

Unary operators are used to perform operations on a single value. These operators include delete, typeof, and void.

Ternary Operators

Ternary operators are used to assign a value based on a condition. These operators include ? (conditional) and : (value).

By understanding the use of each type of operator, you can quickly write more complex expressions in JavaScript. With practice, you will be able to use operators quickly and effectively in your code.

BY: Balmiki Mandal

Related Blogs

Post Comments.

Login to Post a Comment

No comments yet, Be the first to comment.