1function userCreator (name, score) {
2 const newUser = Object.create(userFunctionStore);
3 newUser.name = name;
4 newUser.score = score;
5 return newUser;
6};
7
8const userFunctionStore = {
9 increment: function() {
10 this.score++;
11 },
12
13 login: function() {
14 console.log("Logged in!");
15 }
16};
17
18const user1 = userCreator("Justin", 41);
19const user2 = userCreator("Rainer", 5);
20user1.increment();
21console.log(user1.score) // 42
1function person(fname, lname, age, eyecolor){
2 this.firstname = fname;
3 this.lastname = lname;
4 this.age = age;
5 this.eyecolor = eyecolor;
6}
7
8myFather = new person("John", "Doe", 50, "blue");
9document.write(myFather.firstname + " is " + myFather.age + " years old.");
1let voleur = {
2 action : () =>console.log ('Coup de dague fatal') ,
3 crie : ('pour la horde!!!!') ,
4 coupfatal :()=> console.log ('coup dans le dos')
5
6}
7
8voleur.action() ;
9voleur.coupfatal() ;
10console.log(voleur.crie) ;
11