JavaScript Operators

JavaScript Operators: Operators are used in all programming languages to do calculations, assign, compare and retrieve results from various functions and events. Similarly, JS uses operators to the same. Below are a few JavaScript operators:

Addition: JavaScript uses the sign + for addition of numeric values.

Example: 2+2 the result is 4 in JS.

Concatenation: JavaScript uses plus + sign for concatenating text values.

Example: “Johne” + “Ashbey” would return Johne Ashbey in JS.

Subtract: We use hyphen – sign for subtraction or minus in JavaScript.

Example: 4-2 would result in 2

Multiply: The language JavaScript applies asterisk(*) sign for multiplication.

Example: 4*2 should result 8 in JS.

Divide: JS has / forward slash or division symbol for dividing numbers.

Example: 8/2 will result in 4.

Assignment: Assigning a value to a variable is done using equal sign(=). But keep in mind that it assigns a value to a variable, it does not equate unlike == sign.

Example: var x = 10;

Identity Operator: JavaScript uses (==) double equal sign to check if one value is equal to another or not. The JS returns either true or false after the test is applied:

Example:

Var myScore = 10;

Var myScore == 20;  

The above would reflect in JS as false. 

————————————————————————————

Read More to JavaScript Operators explained:

  1. Using JavaScript Syntax
  2. Learn JavaScript Operators
  3. JavaScript Data Types
  4. JavaScript Variables

Leave a Reply