Last active
April 2, 2016 14:07
-
-
Save goodbedford/8b9ebc25e2bf8cd2ba817260e685c027 to your computer and use it in GitHub Desktop.
intro-js js-assignment-operators.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // = the equal sign is the assignment operator; | |
| var a = 10; // number ten is assigned to variable a; | |
| var b = 20; | |
| var c = 12; | |
| a = c; // a is 12 | |
| console.log("a: " + a); | |
| a = c = b; // a is 20, c is 20, b is 20 | |
| console.log("a: " + a); | |
| // += the plus equal is the addition assignment operator | |
| var a = 10; | |
| console.log("a: " + a); | |
| a += 1; // a is 11; | |
| console.log("a: " + a); | |
| a = a + 1; // a is 12 | |
| console.log("a: " + a); | |
| // -= the minus equal is the subtraction assignment operator | |
| a = 10; | |
| console.log("a:" +a); // a is ten | |
| a -= 1; //a is 9 | |
| console.log("a:" +a); | |
| a = a - 1; //a is 8 | |
| console.log("a:" +a); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment