-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprototype.js
52 lines (44 loc) · 1.16 KB
/
prototype.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
// let myName = "Gauri "
// console.log(myName.truelength);
let myHeroes = ["thor","spiderman"]
let heroPower = {
thor:"Hammer",
spiderman:"sling",
getSpiderPower: function(){
// console.log(`Spider powes is ${this.spiderman}`);
}
}
Object.prototype.gauri = function(){
// console.log(`gauri is present in all objects`);
}
Array.prototype.heyGauri = function(){
// console.log(`Gauri says hello`);
}
// myHeroes.gauri()
// myHeroes.heyGauri()
//heroPower.gauri()
//****************************INHERITANCE*********************************/
const User ={
name:"chai",
email:"[email protected]"
}
const Teacher = {
makeVideo :true
}
const teachingSupport = {
isAvailable: false
}
const TASupport = {
makeAssignment: "JS assignment",
fullTime: true,
__proto__:teachingSupport
}
Teacher.__proto__ = User
//modern syntax
Object.setPrototypeOf(teachingSupport,Teacher)
let anotherUserName = "chaiAurCode "
String.prototype.trueLength = function(){
console.log(`${this}`);
console.log(`true length is ${this.trim().length}`);
}
anotherUserName.trueLength()