-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript-07_Objects_&_Methods.js
64 lines (44 loc) · 1.38 KB
/
script-07_Objects_&_Methods.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
// Using strict mode
// "use strict";
console.log('\n');
// NOTE: WHEN WE ACCESS ANY FUNCTION WITHOUT THE PARENTHESIS(BRACKETS) , WE ARE BASICALLY ACCESSING THE DEFINITION OF THE
// FUNCTION AND NOT THE OUTPUT/RESULT OF THE FUNCTION. BUT WHEN WE ACCESS ANY FUNCTION WITH THE PARENTHESIS , WE ARE ACTUALLY
// ACCESSING THE OUTPUT/RESULT PRODUCED BY THE FUNCTION AND NOT THE DEFINITION OF THE FUNCTION.
function motto()
{
console.log(this);
console.log('\n');
console.log("You have failed this city !!!");
}
motto();
console.log('\n');
let Arrow = {
Alias: "Emrald Archer" ,
Name: "Oliver Queen" ,
Profession: "Vigilante" ,
Skill: "Archery" ,
City: "Starling City" ,
Friends: ["Felicity Smoak" , "Laurel Lance" , "John Diggle" , "Roy Harper" , "Sara Lance"] ,
GirlFriend: "Felicity Smoak" ,
Sisters: ["Thea Queen" , "Emiko Adachi"] ,
Brother: "Tommy Merlyn"
};
Arrow.Motto = motto;
console.log("Arrow description: " , Arrow);
console.log('\n');
Arrow.Description = function()
{
console.log(this);
console.log('\n');
console.log(`My name is ${this.Name} and Iam the Green Arrow !!!`);
}
console.log("Arrow description: " , Arrow);
console.log('\n');
console.log(Arrow.Motto);
console.log('\n');
Arrow.Motto();
console.log('\n');
Arrow.Description();
console.log('\n');
// Arrow.Description;
console.log(Arrow.Description);