Starting Out
- In a Windows machine, use CTRL+SHIFT+J to open up the console. This is where we'll practice applying JavaScript
- There are 7 primitive types in total: number, string, boolean, undefined, null, symbol, and bigint.
- Using the term ** is used for exponentiation: so 2^4 can be expressed as 2**4 in JS. So, 9**2 = 81, 9**3 = 729 etc...
- NaN means 'Not a Number'. However, if we run the typeof operator on it, it will still be recognized as a number
- To elaborate on the previous point, something like "200 +(0/0)" will evaluate to NaN.
Variables and let
let
let variableName = value;
let numHens = 5;
(i.e. so, the number of hens = 5!)
const
const variableName = value;
const daysInWeek = 7;
var
boolean
string
string
This variable follows many of the same rules as those we see in C++!
- One way to find all the functions that you can call upon a string variable is to use the dot
operator. Something new is the .trim() function:
let bobbyNoSentence = " Hey, I'm ready to do it!"; bobbyNoSentence.trim(); //Gives us "Hey, I'm ready to do it!" bobbyNoSentence.trim().toUpperCase(); //Gives us "HEY, I'M READY TO DO IT!";