1let object = {
2 'key1': 'value1',
3 'key2': 'value2',
4 'keyn': 'valuen',
5};
6console.log(object);
1let obj = {
2// fields
3 name:"value",
4 num: 123,
5//methods
6 foo: function(){}
7
8}
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
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