This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Jedi.prototype = Force.prototype; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Force() {} | |
Force.prototype.useForce = function () { | |
return 'I am the Force to be used.'; | |
}; | |
function Jedi() {} | |
Jedi.prototype = new Force(); | |
const luke = new Jedi(); | |
console.log(luke.useForce()); //=> 'I am the Force to be used.' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Force() {} | |
Force.prototype.useForce = function () { | |
return 'I am the Force to be used.'; | |
}; | |
function Jedi() {} | |
Jedi.prototype = { | |
useForce: Force.prototype.useForce | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log(luke.constructor.toString()); | |
/*//=> | |
"function Jedi(){ | |
this.useForce = function(){ | |
return 'I am the Instance'; | |
}; | |
}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Jedi() { | |
this.useForce = function () { | |
return 'I am the Instance'; | |
}; | |
} | |
// 1) nous créons une instance… | |
const luke = new Jedi(); | |
// 2) … ensuite nous attachons la méthode "useForce" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Jedi() { | |
this.useForce = function () { | |
return 'I am the Instance'; | |
}; | |
} | |
// 1) nous attachons la méthode "useForce" au prototype | |
Jedi.prototype.useForce = function () { | |
return 'I am the Prototype'; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Jedi() {} | |
Jedi.prototype.useForce = function () { | |
console.log('I am using the force!'); | |
}; | |
const anakin = Jedi(); | |
const luke = new Jedi(); | |
console.log(anakin instanceof Jedi); //=> false | |
console.log(typeof anakin.useForce); //=> TypeError: anakin is undefined | |
console.log(luke instanceof Jedi); //=> true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const jedi = {}; | |
jedi.name = 'Luke'; | |
jedi.level = 'padawan'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const jedi = {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
mutation | |
AddCommentToIssue { | |
addComment(input: {subjectId: "ISSUE_ID", body: "BODY_CONTENT"}) { | |
clientMutationId | |
} | |
} | |
} |