Skip to content

Instantly share code, notes, and snippets.

View manekinekko's full-sized avatar
:octocat:
Check me out on BlueSky @wassim.dev

Wassim Chegham manekinekko

:octocat:
Check me out on BlueSky @wassim.dev
View GitHub Profile
Jedi.prototype = Force.prototype;
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.'
function Force() {}
Force.prototype.useForce = function () {
 return 'I am the Force to be used.';
};
function Jedi() {}
Jedi.prototype = {
useForce: Force.prototype.useForce
};
console.log(luke.constructor.toString());
/*//=>
"function Jedi(){
this.useForce = function(){
return 'I am the Instance';
};
}"
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"
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';
};
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
const jedi = {};
jedi.name = 'Luke';
jedi.level = 'padawan';
{
mutation
AddCommentToIssue {
addComment(input: {subjectId: "ISSUE_ID", body: "BODY_CONTENT"}) {
clientMutationId
}
}
}