-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharray.js
36 lines (28 loc) · 814 Bytes
/
array.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
var simpleArray = ['hello', 7];
console.log(simpleArray)
// nested array or multi-dimension array
var multiDimArray = [
['hello', 7],
['hey', 3]
]
console.log(multiDimArray)
console.log(multiDimArray[0])
console.log(multiDimArray[0][0])
// Manipulate Array
// ----------------------------------
// modify object in array
simpleArray[0] = 'hello!'
console.log(simpleArray)
// push = append to the last item of the array
simpleArray.push(["happy", 100])
console.log(simpleArray)
// pop = remove last item from array
simpleArray.pop()
console.log(simpleArray)
// shift = remove the first item from array
simpleArray.shift()
console.log(simpleArray)
// unshift = append element to the beginning of the array
simpleArray.unshift("happy")
console.log(simpleArray)
// ----------------------------------