🔥
CS1334
  • Introduction to Programming
  • Algorithm
  • RGB Colormode
  • HSB Colormode
  • Animation
  • Contrasting Concepts - Art
  • Geometric Transform Functions
    • Animation Using Transforms
  • Functions to Draw Characters
  • Functions to Draw Flowers
  • Bounding Box Conditional Branching
  • Canvas Border Constraints
  • Loops Using Math Formulas for Position
  • Finite State Machine
  • Arrays
  • KeyPress Logic
  • Time
  • Collision between objects
  • Buttons
  • Scene Management - State Variables
  • Project 3 - Animation Specification - FSM
  • Project 4 - Animation Logic
  • Project 5
  • Javascript Syntax
    • Variables
    • Indentifiers
    • Functions
    • Variable Scope: Global or Local
    • Logical Operators
    • Numerical Operator Shortcuts
    • Repetition - Loops
Powered by GitBook
On this page

Was this helpful?

  1. Javascript Syntax

Numerical Operator Shortcuts

Some Math Operations are so common that many languages provide shortcut syntax, for example: x = x + 1; can also be written as x++, or as x += 1;

When modifying the value of a variable based on the current value of the variable, the syntax for addition would be:

var x = 10;

x = x + 3;  // increment x by 3

x = x - 4;  // decrease x by 4

x = x * 2 // multiply x by 2

x = x / 5 //divide x by 5

///The shortcut syntax for the above

x += 3; 

x -= 4;

x *= 2;

x /= 5;
PreviousLogical OperatorsNextRepetition - Loops

Last updated 5 years ago

Was this helpful?