Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

README.md

Lesson 04

In this lesson we learned how to use the javascript operators.

Contents

Arithmetic Operators

  • 5 + 2 = 7
  • 5 - 2 = 3
  • 5 * 2 = 10
  • 5 / 2 = 2.5
  • 5 % 2 = 1
  • 5 ** 2 = 25

The arithmetic operators, in javascript, follows the standard precedence of math operators.

Assignment Operators

  • n = 2
  • n += 2
  • n -= 2
  • n *= 2
  • n /= 2
  • n %= 2
  • n %= 2
  • n **= 2
  • n++
  • n--

Relational Operators

  • >: greater than;
  • <: less than;
  • >=: greater or equal than;
  • <=: less or equal than;
  • ==: equal to;
  • !=: different to.

The result of an relational operation is a boolean value.

Identity Operator

In javascript exists the identity operator: ===. This operator tests if the operators are identical.

Logical Operators

  • !: negation (not);
  • &&: conjunction (and);
  • ||: disjunction (or).

Ternary Operator

In javascript we have a special type of operator: the ternary operator. This operator is identified by ? and : symbols.

Structure

test ? true : false

Precedence of Types of Operators

  1. Arithmetic;
  2. Relational;
  3. Negation;
  4. Conjunction;
  5. Disjunction;
  6. Ternary;
  7. Assignment.