Classes

class Person { // Will be called when instnatiating person constructor(name) { this.name = name; console.log('A person named "' + name + '" is born'); } // No need to write function keyword sayHello() { console.log(this.name + ' says hello'); } } // Extend it without using prototype class Employee extends Person { constructor(name) { super(name); console.log(this.name + ' has been employed'); } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.