Javascript Flashcards
Variable
“name storage” for data. Use ‘let’ to create a variable in Javascript. Variable is right after.
Show 2 variables coping data.
let hello = ‘hello world!’;
let message;
message = hello world;
How many times should a variable be declared ?
Once
Variable Limitations
- Name MUST contain letters, numbers or symbols $ and _
2. First character must not be a digit
Valid Variable Names
- let userName;
- let test123;
- let $;
4 let _;
Does case matter ?
YES!!
apple and AppLE are two different variables.
Reserved names
let class return function
Use strict
Allow you not to use ‘let’, as long as you define to use strict.
Must put: “use strict”;
Constants
Declare a constant(UNCHANGING) variable, uses ‘const’ instead of ‘let’
Can ‘const’ be reassigned ?
NO!
Uppercase constants
used for difficult to remember values that are known prior to execution
When do you use uppercase constants?
When variable values never change. Ex. color codes, birthdays etc.
Infinity
is a special value that is greater than any number.
- alert (1/0);
- alert(Infinity);
How many special numeric values are there ?
- Infinity, -Infinity and NaN
NaN
represent a computational error. It is a result of a incorrect or undefined math operation