Skip to content

Instantly share code, notes, and snippets.

View anurag-majumdar's full-sized avatar
💭
Creativity is the art of application of learning.

Anurag Majumdar anurag-majumdar

💭
Creativity is the art of application of learning.
View GitHub Profile
// ES6 style
class Animal {
constructor(name, weight) {
this.name = name;
this.weight = weight;
}
//...
}
// Check Type of ES6 class
function Animal(name, weight) {
this.name = name;
this.weight = weight;
}
Animal.prototype.eat = function() {
return `${this.name} is eating!`;
}
Animal.prototype.sleep = function() {
@anurag-majumdar
anurag-majumdar / ES6.js
Last active December 22, 2022 06:45
Inheritance in JavaScript using ES6 keywords super and extends.
class Animal {
constructor(name, weight) {
this.name = name;
this.weight = weight;
}
eat() {
return `${this.name} is eating!`;
}