javascript all operators code example
Example 1: JavaScript Operators
var x = 5; // assign the value 5 to x
var y = 2; // assign the value 2 to y
var z = x + y; // assign the value 7 to z (5 + 2)
Example 2: what does -= mean in JavaScript
/* JavaScript shorthand -=
-= is shorthand to subtract something from a
variable and store the result as that same variable.
*/
// The standard syntax:
var myVar = 5;
console.log(myVar) // 5
var myVar = myVar - 3;
console.log(myVar) // 2
// The shorthand:
var myVar = 5;
console.log(myVar) // 5
var myVar -= 3;
console.log(myVar) // 2