-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathscript.js
More file actions
73 lines (50 loc) · 1.79 KB
/
script.js
File metadata and controls
73 lines (50 loc) · 1.79 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//constant are read only - you have to declare and initiaize on a cnstant
// escape character \\ or use back ticks/template literals ``
let a = 45
let description = "wise"
a = 35
console.log(a)
console.log(`this is a ${a} year old man`)
console.log(`this is a ${description} old man`)
//Array literals
const numbers = [1, 2, 3, 4, 5, 5, 6]
numbers[2] = 11 //mutating the array. this is not reasigning the array that is why we can do it on a const defined array
console.log(numbers[4])
// ARRAY methods
//pop() shift() push(item)
// we can have items of different types of data in an array, strings , numbers, arrays , boolean, null
// Object literals
const person = {
firstName: "John",
secondName: "Smith",
age: 30,
pets: ["dogs", "cats"],
address: {
street: "123 Street",
city: "Johanesburg",
State: "Kitale"
}
}
person.email = "johnsmith@email.com"
console.log(person.firstName)
console.log(person['secondName'])
console.log(person.address.State)
console.log(person)
// const - let then var as last thought case
//// *******STRICT EQUALITY****
console.log("%cInterger and string", "color:green")
console.log("1" == 1) //true
console.log("1" === 1) //false
console.log("%cZero and space", "color:green")
console.log(0 == "") //true
console.log(0 === "") //false
console.log("%cZero and boolean")
console.log(0 == false) //true
console.log(0 === false) //false
console.log(1 == true) //true
console.log(1 === true) //false
console.log("%cUse case for double oppperator: on null and undefined", "color:red ; font-size:20px")
console.log(null == undefined) //true
console.log(null === undefined) //false
console.log("%c != works the same as ==", "color:green ; font-size:20px")
console.log("%c !== works the same as ===", "color:green ; font-size:20px")