-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprototype.js
More file actions
61 lines (44 loc) · 1.28 KB
/
prototype.js
File metadata and controls
61 lines (44 loc) · 1.28 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
//let myName = "aameen "
//let myChannel = "tryYoutube "
//console.log(myName.trueLength);
let myHeros = ["thor", "spiderman"]
let heroPower = {
thor:"hammer",
spiderman:"sling",
getSpiderPower: function(){
console.log(`Spidy power is ${this.spiderman}`);
}
}
Object.prototype.aamin = function(){
console.log(`aamin is present in all objects`);
}
Array.prototype.heyAamin = function(){
console.log(`Hitesh says hello`);
}
//heroPower.aamin()
//myHeros.aamin()
//myHeros.heyAamin()
//heroPower.heyAamin()
const Teacher = {
makevideo:true
}
const TeachingSupport = {
isAvailable: false
}
const TASupport = {
makeAssignment:'JS assignment',
fullTime: true,
__proto__:TeachingSupport
}
// Teacher.__proto__ = User
//modern Syntax
//OBJECT.SETPROTOTYPEOF: Sets the prototype of a specified object o to object proto or null.Returns the object o
Object.setPrototypeOf(TeachingSupport,Teacher)
let anotherUserName = "ChaiAurCode "
String.prototype.trueLength = function(){
console.log(`${this}`);
console.log(`True length is: ${this.trim().length}`);
}
anotherUserName.trueLength()
"aamin".trueLength()
"iceTea".trueLength()