variables & datatypes Flashcards
Shorten the below
let user = ‘John’;
let age = 25;
let message = ‘Hello’;
let user = ‘John’, age = 25, message = ‘Hello’;
let hello = ‘Hello world!’;
let message;
message = hello;
alert(hello); // returns?
alert(message); // returns?
Hello world!
Hello world!
varibles cannot start with a _____ or have a _____
digit
hyphon
reserved variable words
let, class, return, function
Besides regular numbers, there are so-called “special numeric values” which also belong to this data type; name the 3
Infinity, -Infinity and NaN.
alert( 1 / 0 ); // returns
infinity
alert( “not a number” / 2 )
returns?
infinity
alert( NaN + 1 ); // returns
NAN
alert( 3 * NaN ); // returns
NAN
alert( “not a number” / 2 - 1 )
// returns
NAN
So, if there’s a NaN somewhere in a mathematical expression, it propagates to the whole result (there’s only one exception to that: )
NaN ** 0 is 1
let name = “John”;
// embed a variable
alert( Hello, \_\_\_\_\_\_ !
); // Hello, John!
${name}
The expression inside ${…} is evaluated and the result becomes a part of the string but can only be done with ______.
backticks
``
______ is just a special value which represents “nothing”, “empty” or “value unknown”.
NULL
The meaning of ________ is “value is not assigned”.
undefined