1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| function Person(name, age) { this.name = name; this.age = age; this.location = location; }
Person.prototype.getName = function () { return this.name + ' 입니다.'; }
=============================================
class Person { constructor(name, age) { this.name = name; this.age = age; this.location = location; }
getName() { return this.name + ' 입니다.'; } }
const one = new Person('one', 1, 'Korea'); const two = new Person('two', 2, 'Korea');
console.log(one.getName());
|