An assignment operator assigns a value to its left operand based on the value of its right operand. The most common assignment operator is = , which just assigns the value of an expression to a variable, like this line of code we've already seen: var kilograms = pounds / 2.2046 The other assignment operators are shorthand assignment operators . How do they work? If you want to add one to a value, you can do so as follows : todaysDate = todaysDate + 1 However, using the += shorthand operator, you can do this a little easier, like this: todaysDate += 1 In other words, the statement todaysDate = todaysDate + 1 does the same thing as the statement todaysDate += 1 . You can use either in your code. Table 2.6 lists the JavaScript shorthand assignment operators. Table 2.6. JavaScript Shorthand Assignment Operators
|