WDI Fundamentals Unit 7
Here are some notes on what's been covered in this chapter. Feel free to copy this information and extend it to make your own cheat sheet.
A variable is assigned a value using the
= operator. First, the expression to the right of the
= is evaluated. Then, this value is assigned to the variable to the left of the
var favoriteMovie = "Jaws"; favoriteMovie; // => "Jaws"
When a variable is reassigned, it retains no knowledge of any prior values it may have held.
var winner = "Sarah"; winner = "Jeff"; winner; // => "Jeff"
x = x + 1(or its shorthand,
x += 1).
x = yonly means that the value that
yhad been holding is now also held in
x. It does not imply any lasting relationship between x and y.
=operator assigns a value to a variable.
+=operator adds a value to an existing variable.
-=operator subtracts a value from an existing variable.
To check to see what type of data a variable holds, the
typeof operator can be used.
var myPet = "Arthur"; typeof myPet; // => "string"
2) and operators (like
+operator with two strings literally puts them next to each other, instead of evaluating their total. This is called string concatenation.
Feeling confident? Let's take what we've learned and apply it to a project.