• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
JavaScriptSource

JavaScriptSource

Search 5,000+ Free JavaScript Snippets

  • Home
  • Browse Snippets
    • Addon
    • Ajax
    • Buttons
    • Cookies
    • CSS
    • Featured
    • Forms
    • Games
    • Generators
    • Image Effects
    • Math Related
    • Miscellaneous
    • Multimedia
    • Navigation
    • Page Details
    • Passwords
    • Text Effects
    • Time & Date
    • User Details
Home / Basics / JavaScript Operators Explained

JavaScript Operators Explained

JavaScript Operators Explained

Operators are the symbols between values that allow different operations like addition, subtraction, multiplication, and more.

JavaScript has dozens of operators, so let’s focus on the ones you’re likely to see most often.

Arithmetic

The + operator adds two numbers.

// EXAMPLE
1 + 2;

// OUTPUT
3

The – operator subtracts one number from another.

// EXAMPLE
3 * 12;

// OUTPUT
36

Grouping

() operator groups other values and operations. Code located between parentheses evaluates first as JavaScript solves each operation moving from left to right.

Adding the grouping operator to the previous example causes 1 + 100 to evaluate first.

// EXAMPLE
(1 + 100) * 5;

// OUTPUT
505

Concatenation

The + operator can also concatenate strings, which is another way of saying it can add them together.

// EXAMPLE
"news" + "paper";

// OUTPUT
"newspaper"

Assignment

The = operator assigns values. It’s used for setting the value of variables.

// EXAMPLE
var dinner = "sushi";

Source

https://www.javascript.com/learn/operators

Basics

Related Snippets:

  • The onblur Event in JavaScript
  • JavaScript Objects Explained
  • How To Convert a String to Boolean in JavaScript
  • The JavaScript function Math.abs()

Primary Sidebar

Popular Posts

Story Generator

IP Grabber – get a users IP address with JavaScript

Simple Calendar

Remove Ads

Astrological Calculator

Copyright © 2025 JavaScriptSource.com

  • About
  • Privacy Policy
  • FAQ
  • Jobs For Developers