-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path02-data-types.html
43 lines (37 loc) · 1.3 KB
/
02-data-types.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
//Name convention: CamelCase.
//JavaScript has the concept of primitive data types. These are built into the language, but they're not objects.
//String
const palindrome = "tacocat";
const occupation = "Hand Model";
const password = "t3h@&$&()";
//Numbers
const apy = 1.5;
const numberOfConcerts = 1000;
//Booleans
const isOlderThan21 = false;
const hasNewCarSmell = true;
//Undefined vs. null
//Undefined = Default value when creating a variable. A variable has been declared but has not yet been assigned a value.
//Null = The variable exist but the value is NULL.
//null === undefined // false
//null == undefined // true
//null === null // true
var testVar;
alert(testVar); //shows undefined
alert(typeof testVar); //shows undefined
var testVar = null;
alert(testVar); //shows null
alert(typeof testVar); //shows object
</script>
</body>
</html>