7554425D-0054-440D-B95E-D2ABC13D62CD Created with sketchtool.
{body}
Your Saved Info Packages

View your saved Course or Program Packages containing pricing and detailed curriculum.

Speak with a Learning Advisor.

Have any questions? We'll call you.

Fill out the form below and a Learning Advisor will reach out at a time convenient for you.

Please pick a valid date and time between 9 AM and 8 PM eastern (Monday to Friday)

By clicking "Book a call," you accept our Terms and will also receive exclusive offers and updates about new courses, workshops and events.

JavaScript Tutorial

JavaScript Operators

Ready to start your career in Development? Find out more about BrainStation's Web Development Bootcamp

Quite often Developers have to write code that does mathematical and logical calculations. JavaScript provides a very comprehensive list of operators which can be used to perform such tasks. Operators in JavaScript are broadly divided as:

  • Arithmetic Operators
  • Increment/Decrement Operators
  • Assignment Operators
  • Comparison Operators

Arithmetic Operators

Increment & Decrement Operators

Increment (two plus sign) ++ & Decrement (two minus sign) -- Operators are used to increase or decrease the value of a variable by 1. Depending on whether the operator sign is used before or after the variable, it produces a different result. However, it still increments or decrements by 1.

```
let count = 0;
console.log(count); // prints 0
count++; // first assign the current value back to count and then increase it by 1
++count; // first increase the value by 1 and then assign the new value to count
```

Assignment Operators

Assignment operator or equal sign = is used for assigning the value on the right hand side of equal sign to the variable on the left hand side of the equal sign. It is the most commonly used operator in JavaScript as there is always a need for assigning the value to a variable.

Increment and Decrement Operators also have a shorthand notation that uses the assignment operator. While increment operator ++ and decrement operator -- is used to increase or decrease the value by 1, sometimes there is a need to increase or decrease the value by a different amount. In this case a variation of increment += and decrement -= is used.

Comparison Operators

While writing code in JavaScript, there is always a need to make logical decisions in code. Comparison operators are often used while writing logical statements. They compare two values and return a boolean value either true or false. All the values are either truthy or falsy in JavaScript and hence using comparison operators always returns a true or false value.

One key thing to note here is that JavaScript allows both non-strict == and strict === comparison of two values. It is highly recommended that Developers in JavaScript always use triple equal sign === or strict equality comparison. == sign compares only the values to be either truthy or falsy while === compares both the values and as well the type of both the values to be equal for a more strict comparison.

Set Password

You already have an account with BrainStation, but you still need to set up a password.