Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • Software and Tools
    • School Learning
    • Practice Coding Problems
  • Go Premium
  • JS Tutorial
  • JS Exercise
  • JS Interview Questions
  • JS Array
  • JS String
  • JS Object
  • JS Operator
  • JS Date
  • JS Error
  • JS Projects
  • JS Set
  • JS Map
  • JS RegExp
  • JS Math
  • JS Number
  • JS Boolean
  • JS Examples
  • JS Free JS Course
  • JS A to Z Guide
  • JS Formatter
Open In App
Next Article:
JavaScript Assignment Operators
Next article icon

JavaScript Operators Reference

Last Updated : 04 Jul, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

JavaScript Operators are used to perform specific mathematical and logical computations on operands. In other words, an operator operates the operands. In JavaScript, operators are used to compare values, perform arithmetic operations, etc.

Example: In this example, we will use typeof operator to check the type of variable.

JavaScript
let a = 17;
let b = "GeeksforGeeks";
let c = "";
let d = null;

console.log("Type of a = " + (typeof a));
console.log("Type of b = " + (typeof b));
console.log("Type of c = " + (typeof c));
console.log("Type of d = " + (typeof d));
console.log("Type of e = " + (typeof e));

Output
Type of a = number
Type of b = string
Type of c = string
Type of d = object
Type of e = undefined

The Complete List of JavaScript Operators is listed below:

JavaScript Arithmetic Operators

These are the operators that work on numerical values and then return a number. These are basically used to perform mathematical operations.

OPERATOR NAME

OPERATION

Addition (+)Add two numbers or concatenate the string.
Subtraction (-)Difference between the two operators.
Multiplication (*)Multiply two numbers.
Division (/)Find the quotient of two operands.
Modulus (%)Find the remainder of two operands.
Exponentiation (**)Raise the Left operator to the power of the right operator.
Increment (++)Increase the operand by one.
Decrement (--)Decrease the operand by one.
Unary Plus (+)Converts non-numbers to numbers.
Unary Negation (-)Converts operand to negative.

JavaScript Comparison Operators

These are the operators that are used to perform equality or difference comparisons between the values. It checks whether an element is greater, smaller equal, or unequal to the other element.

OPERATOR NAME

OPERATION

Equality (==)Compares the equality of two operators.
Inequality (!=)Compares inequality of two operators.
Strict Equality (===)Compares both value and type of the operand.
Strict Inequality (!==)Compares inequality with type.
Greater than (>)Checks if the left operator is greater than the right operator.
Greater than or equal (>=)Checks if the left operator is greater than or equal to the right operator.
Less than (<)Checks if the left operator is smaller than the right operator.
Less than or equal (<=)Checks if the left operator is smaller than or equal to the right operator.

JavaScript Logical Operators

These are the operators which allow us to compare variables or values. The logical operator is mostly used to make decisions based on conditions specified for the statements. It can also be used to manipulate a boolean or set termination conditions for loops.

OPERATOR NAMEOPERATION
NOT (!)Converts operator to boolean and returns flipped value.
AND (&&)Evaluates operands and return true only if all are true.
OR (||)Returns true even if one of the multiple operands is true.

JavaScript Bitwise Operators

These operators convert the number to a 32-bit binary number and perform the bitwise operation. The number is converted back to the 64-bit number after the result. 

OPERATOR NAMEOPERATION
Bitwise AND (&)Returns true if both operands are true.
Bitwise OR (|)Returns true even if one operand is true.
Bitwise XOR (^)Returns true if both operands are different.
Bitwise NOT (~)Flips the value of the operand.
Bitwise Left Shift (<<)Shifts the bit toward left.
Bitwise Right Shift (>>)Shifts the bit towards the right.
Zero Fill Right Shift (>>>)Shifts the bit towards the right but adds 0 from the left.

JavaScript Assignment Operators

These operators assign the value of the right-hand operand to its left-hand operand. That is if a = b assigns the value of b to a.

OPERATOR NAMEOPERATION
Addition Assignment (+=)Add the value of the right operand to left and assign it to the left operand.
Subtraction Assignment (-=)Subtracts the value of the right operand to left and assigns it to the left operand.
Multiplication Assignment (*=)Multiplies the value of the right operand to left and assign it to the left operand.
Division Assignment (/=)Divides the value of the right operand by the left and assigns it to the left operand.
Remainder Assignment (%=)Finds the remainder after the division of the right operand with the left and assign it to the left operand.
Exponentiation Assignment (**=)Raises left operand to power of right operand and assign it to the left operand.
Left Shift Assignment (<<=)Moves the bits specified on the right operand to left and then assigns it to the left operand.
Right Shift Assignment (>>=)Moves the bits specified on the right operand to right and then assigns it to the left operand.
Bitwise AND Assignment (&=)Does a bitwise AND operation of both operands and assign it to the left operand.
Bitwise OR Assignment (|=)Does a bitwise OR operation of both operands and assign it to the left operand.
Bitwise XOR Assignment (^=)Does a bitwise XOR operation of both operands and assigns it to the left operand.

Few Important JavaScript Operators

OPERATOR NAMEOPERATION
Ternary (?:)Used as a simplified version of if-else to reduce code lines.
typeof A keyword to return the data type of the operand.
conditionalUsed to perform operations according to conditions.
instanceofUsed to check the type of operator at runtime.
DeleteUsed to delete JavaScript object properties.
in Keyword used to check if a property exists or not.
Spread (...)A new feature is used to expand iterables in form of an array.
comma (,)Used to separate operands.
GroupingUsed to override normal operator precedence.
Unary (+_) Converts the type of variable to the number.
Short circuitingUsed for evaluating an expression.
Nullish Coalescing (??) Used to return a value if the value is undefined or null.
Unsigned right bit shift (>>>)Used as unsigned right bit shift operator.
Pipeline (|>)Used to pipe the value of an expression to function.
Optional chaining (?.)Error-proof way to access nested object properties.
ArrowShortcut way of writing a function.

To learn about the precedence of these operators check this article Operator precedence in JavaScript


Next Article
JavaScript Assignment Operators

K

kartik
Improve
Article Tags :
  • JavaScript
  • Web Technologies
  • javascript-operators

Similar Reads

    JavaScript Operators
    JavaScript operators are symbols or keywords used to perform operations on values and variables. They are the building blocks of JavaScript expressions and can manipulate data in various ways.JavaScript OperatorsThere are various operators supported by JavaScript.1. JavaScript Arithmetic OperatorsAr
    5 min read
    JavaScript Operators
    JavaScript operators are symbols or keywords used to perform operations on values and variables. They are the building blocks of JavaScript expressions and can manipulate data in various ways.JavaScript OperatorsThere are various operators supported by JavaScript.1. JavaScript Arithmetic OperatorsAr
    5 min read
    JavaScript Operators Coding Practice Problems
    Operators in JavaScript allow you to perform operations on variables and values, including arithmetic, logical, bitwise, comparison, and assignment operations. Mastering JavaScript operators is essential for writing efficient expressions and conditional statements. This curated list of JavaScript op
    1 min read
    JavaScript Assignment Operators
    Assignment operators are used to assign values to variables in JavaScript.JavaScript// Lets take some variables x = 10 y = 20 x = y ; console.log(x); console.log(y); Output20 20 More Assignment OperatorsThere are so many assignment operators as shown in the table with the description.OPERATOR NAMESH
    5 min read
    JavaScript Assignment Operators
    Assignment operators are used to assign values to variables in JavaScript.JavaScript// Lets take some variables x = 10 y = 20 x = y ; console.log(x); console.log(y); Output20 20 More Assignment OperatorsThere are so many assignment operators as shown in the table with the description.OPERATOR NAMESH
    5 min read
    JavaScript Course Operators in JavaScript
    An operator is capable of manipulating a certain value or operand. Operators are used to performing specific mathematical and logical computations on operands. In other words, we can say that an operator operates the operands. In JavaScript, operators are used for comparing values, performing arithm
    7 min read
`; $(commentSectionTemplate).insertBefore(".article--recommended"); } loadComments(); }); }); function loadComments() { if ($("iframe[id*='discuss-iframe']").length top_of_element && top_of_screen articleRecommendedTop && top_of_screen articleRecommendedBottom)) { if (!isfollowingApiCall) { isfollowingApiCall = true; setTimeout(function(){ if (loginData && loginData.isLoggedIn) { if (loginData.userName !== $('#followAuthor').val()) { is_following(); } else { $('.profileCard-profile-picture').css('background-color', '#E7E7E7'); } } else { $('.follow-btn').removeClass('hideIt'); } }, 3000); } } }); } $(".accordion-header").click(function() { var arrowIcon = $(this).find('.bottom-arrow-icon'); arrowIcon.toggleClass('rotate180'); }); }); window.isReportArticle = false; function report_article(){ if (!loginData || !loginData.isLoggedIn) { const loginModalButton = $('.login-modal-btn') if (loginModalButton.length) { loginModalButton.click(); } return; } if(!window.isReportArticle){ //to add loader $('.report-loader').addClass('spinner'); jQuery('#report_modal_content').load(gfgSiteUrl+'wp-content/themes/iconic-one/report-modal.php', { PRACTICE_API_URL: practiceAPIURL, PRACTICE_URL:practiceURL },function(responseTxt, statusTxt, xhr){ if(statusTxt == "error"){ alert("Error: " + xhr.status + ": " + xhr.statusText); } }); }else{ window.scrollTo({ top: 0, behavior: 'smooth' }); $("#report_modal_content").show(); } } function closeShareModal() { const shareOption = document.querySelector('[data-gfg-action="share-article"]'); shareOption.classList.remove("hover_share_menu"); let shareModal = document.querySelector(".hover__share-modal-container"); shareModal && shareModal.remove(); } function openShareModal() { closeShareModal(); // Remove existing modal if any let shareModal = document.querySelector(".three_dot_dropdown_share"); shareModal.appendChild(Object.assign(document.createElement("div"), { className: "hover__share-modal-container" })); document.querySelector(".hover__share-modal-container").append( Object.assign(document.createElement('div'), { className: "share__modal" }), ); document.querySelector(".share__modal").append(Object.assign(document.createElement('h1'), { className: "share__modal-heading" }, { textContent: "Share to" })); const socialOptions = ["LinkedIn", "WhatsApp","Twitter", "Copy Link"]; socialOptions.forEach((socialOption) => { const socialContainer = Object.assign(document.createElement('div'), { className: "social__container" }); const icon = Object.assign(document.createElement("div"), { className: `share__icon share__${socialOption.split(" ").join("")}-icon` }); const socialText = Object.assign(document.createElement("span"), { className: "share__option-text" }, { textContent: `${socialOption}` }); const shareLink = (socialOption === "Copy Link") ? Object.assign(document.createElement('div'), { role: "button", className: "link-container CopyLink" }) : Object.assign(document.createElement('a'), { className: "link-container" }); if (socialOption === "LinkedIn") { shareLink.setAttribute('href', `https://www.linkedin.com/sharing/share-offsite/?url=${window.location.href}`); shareLink.setAttribute('target', '_blank'); } if (socialOption === "WhatsApp") { shareLink.setAttribute('href', `https://api.whatsapp.com/send?text=${window.location.href}`); shareLink.setAttribute('target', "_blank"); } if (socialOption === "Twitter") { shareLink.setAttribute('href', `https://twitter.com/intent/tweet?url=${window.location.href}`); shareLink.setAttribute('target', "_blank"); } shareLink.append(icon, socialText); socialContainer.append(shareLink); document.querySelector(".share__modal").appendChild(socialContainer); //adding copy url functionality if(socialOption === "Copy Link") { shareLink.addEventListener("click", function() { var tempInput = document.createElement("input"); tempInput.value = window.location.href; document.body.appendChild(tempInput); tempInput.select(); tempInput.setSelectionRange(0, 99999); // For mobile devices document.execCommand('copy'); document.body.removeChild(tempInput); this.querySelector(".share__option-text").textContent = "Copied" }) } }); // document.querySelector(".hover__share-modal-container").addEventListener("mouseover", () => document.querySelector('[data-gfg-action="share-article"]').classList.add("hover_share_menu")); } function toggleLikeElementVisibility(selector, show) { document.querySelector(`.${selector}`).style.display = show ? "block" : "none"; } function closeKebabMenu(){ document.getElementById("myDropdown").classList.toggle("show"); }
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences