Javascript Assignement Flashcards
Assignment operators assign values to JavaScript variables.
1
Q
Assignment operators assign values to JavaScript variables.
Assignments take place in the order that operations are written in code. So variable values change as the code is read and operations occur.
A
Operator Example Same As = x = y x = y \+= x += y x = x + y -= x -= y x = x - y *= x *= y x = x * y
The **= operator is an experimental part of the ECMAScript 2016 proposal (ES7). It is not stable across browsers. Do not use it.
2
Q
Assignment Examples
The = assignment operator assigns a value to a variable.
The += assignment operator adds a value to a variable.
The *= assignment operator multiplies a variable.
A
var x = 10; document.getElementById("demo").innerHTML = x;
var x = 10;
x += 5;
becomes 15 in the browser
var x = 10;
x *= 5;
becomes 50 in the browser