js class
-
5. class vs objectJavaScript & TypeScript 2020. 11. 14. 11:06
class template declare once no data in introduced in ES6 syntactical sugar over prototype-based inheritance 1. class declarations class Person { // constructor constructor (name, age) { // fields this.name = name; this.age = age; } // methods speak() { console.log(`${this.name}: hello! `); } } const ellie = new Person('ellie', 20); console.log(ellie.name); // ellie console.log(ellie.age); // 20 ..