forked from IISSI2-IS-profs/JavascriptTutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
3.dataTypes.js
42 lines (36 loc) · 976 Bytes
/
3.dataTypes.js
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
// boolean, string, number (decimal or not), object
const isEmpty = true
const message = 'Hello!'
const size = 3
const height = 1.75
// Object
const person = {
firstName: 'John',
lastName: 'Doe',
fullName: function () {
return this.firstName + ' ' + this.lastName
}
}
person.firstName = 'Paul'
console.log(person.fullName()) // Prints Paul Due
person = { firstName: 'Paul' } // Error: assignment to constant variable
// Array
const cars = [ 'Saab', 'Volvo', 'BMW' ]
console.log(cars[0])
// const height = 1.75
// Comparison for equal values
if (height == 1.75) {
console.log('height == 1.75 is true')
}
if (height == '1.75') {
console.log('height == \'1.75\' is true')
}
// Comparison for equal values and types
if (height === 1.75) {
console.log('height === 1.75 is true')
}
if (height === '1.75') {
console.log('height === \'1.75\' is true')
} else {
console.log('height === \'1.75\' is false')
}