-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCollectionOfValue.js
More file actions
61 lines (46 loc) · 1.34 KB
/
CollectionOfValue.js
File metadata and controls
61 lines (46 loc) · 1.34 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
const array = ["a", "b", "c"]
let indexOfTwo = array.indexOf("b");
console.log(indexOfTwo)
console.log(array[indexOfTwo - 1])
console.log(array[indexOfTwo + 1])
array.push(4)
console.log(array)
const Animals = ["cat", "dog", "cow", "tiger", "monkey", "snake", "duck"]
console.log("Length of Array is : ", Animals.length)
console.log(Animals[5])
const multiDimensionalArray = [
[1, 2, 3, 4],
[4, 5, 6],
[7, 8, 9]
]
console.log(multiDimensionalArray)
console.log(multiDimensionalArray[0][0])
console.log(multiDimensionalArray.length)
console.log(multiDimensionalArray[0].length)
//Objects (hash tables)
const object = {
property1 : "I",
property2 : "am an",
property3 : "Object"
}
console.log(object)
console.log(object.property1 + object.property2 + " " + object.property3)
let newObject = {
property1 : "Hello",
property2 : function(){
console.log("I am method now.")
}
}
console.log(newObject)
console.log(newObject.property1)
// or object property call
console.log(newObject["property1"])
newObject.property2();
let personOneLikeFoodItem = {
// item : price
egg : 10,
pizza : 100,
chicken : 120,
desert : 200
}
console.log("Total cost of person one : ", personOneLikeFoodItem["egg"] + personOneLikeFoodItem["desert"] + personOneLikeFoodItem["chicken"] + personOneLikeFoodItem["pizza"]);