For each expression, predict what you think the output will be in a comment (//
) without first running the command. Then run the expression in the console. Note the actual output in a comment and compare it with your prediction.
You may run these commands inside the Dev Tool console to double check your answer!
typeof("15")
// Prediction: Number
// Actual: String
What is the output of each of the expressions below?
typeof(15)
// Prediction:
// Actual:
typeof(5.5)
// Prediction:
// Actual:
typeof(NaN)
// Prediction:
// Actual:
typeof("hello")
// Prediction:
// Actual:
typeof(true)
// Prediction:
// Actual:
typeof(1 != 2)
// Prediction:
// Actual:
"hamburger" + "s"
// Prediction:
// Actual:
"hamburgers" - "s"
// Prediction:
// Actual:
"1" + "3"
// Prediction:
// Actual:
"1" - "3"
// Prediction:
// Actual:
"johnny" + 5
// Prediction:
// Actual:
"johnny" - 5
// Prediction:
// Actual:
99 * "luftbaloons"
// Prediction:
// Actual:
What's going on in the second half of the previous question? Are there any "rules" we can pull from those examples?