-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
54 lines (37 loc) · 793 Bytes
/
Copy pathapp.js
File metadata and controls
54 lines (37 loc) · 793 Bytes
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
console.log('hello world');
function sayHello(word){
console.log("hello "+ word);
}
sayHello("David");
// Method 1
var o = { };
o.name = "David";
o.address = "123 Main Street";
o.age = 19;
o.age += 5;
o.sayHello = function(){
console.log("Hello object method");
}
o.sayHello();
o.sayHello2 = sayHello;
// Method 2
var o2 = {
name: "David",
address: "123 Main Street",
age: 19 +5,
sayHello: function(){
console.log("hello, object method!!");
},
fruit: ["Apples", "Oranges", "Kiwi"]
};
o2.sayHello();
o2.age +=5;
o2.name = "Mr. " + o2.name + " jones";
var myArray = ["Apples", "Oranges", "Kiwi"];
myArray.forEach(function(element, index){
console.log(element , index);
})
console.log(myArray[0]);
console.log(o2.fruit[0]);
console.log(o);
console.log(o2);