-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata-types.js
75 lines (56 loc) · 1.08 KB
/
data-types.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
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
74
75
//* DATA TYPES : 1. Primitive Types 2. Reference Types */
/**
* * 1. Primitive Types
*
* * String
* * Number
* * Boolean
*
* * Undefined
* * Null
* Symbol
*
* * Bigint ( A New Primitive Types in 2020)
*
*/
const name = 'Kitty' // String
let height = 120 // Number
let isFemale = true // Boolean
let country // undefined
let city = null // null
let bigNumber = 10n // bigint
console.log(bigNumber)
/**
* * 2. Reference Types
*
* * Object
* * Array
* * Function
*/
// * Object
const person = {
name: 'Ken',
isMale: true,
age: 8
}
console.log(person)
console.log(person.name)
person.age = 12
console.log(person)
person.nationality = 'british'
console.log(person)
// * Array
const numbers = [5, 10, 15, 20]
console.log(numbers[2])
// Add new element at the end of the array
numbers.push(25)
console.log(numbers)
// Add new element to the beginning of the array
numbers.unshift(0)
console.log(numbers)
// Delete the lastest element of the array
numbers.pop()
console.log(numbers)
// Delete the first element of the array
numbers.shift()
console.log(numbers)