SHOW:
|
|
- or go back to the newest paste.
| 1 | <script> | |
| 2 | name ="maxime" | |
| 3 | otherName = "yugi-ho" | |
| 4 | ||
| 5 | function Person(name){
| |
| 6 | this.name = name; | |
| 7 | } | |
| 8 | ||
| 9 | Person.prototype.greet = function(otherName){
| |
| 10 | return "Hi " + otherName + ", my name is " + name; | |
| 11 | } | |
| 12 | ||
| 13 | - | console.log(Person.greet(name,otherName)) |
| 13 | + | var maxime = new Person("maxime"); //la variable maxime est une instance de Person.
|
| 14 | - | |
| 14 | + | console.log(maxime.greet(otherName)) //On dis a maxime de saluer otherName |
| 15 | //Tada | |
| 16 | </script> |