CHALLENGE
class Animal {
constructor(name) {
this.name = name;
}
speak() {
return `${this.name} makes a sound`;
}
}
class Dog extends Animal {
speak() {
return super.speak() + ' and barks';
}
}
const pet = new Dog('Rex');
console.log(pet.speak());
console.log(pet instanceof Animal);
console.log(pet.constructor.name);
β€2
What is the output?
Anonymous Quiz
48%
Rex makes a sound and barks true Dog
21%
Rex barks false Dog
21%
Rex makes a sound and barks true Animal
10%
Rex makes a sound true Dog
π8π€1
Each year, Devographics runs an epic survey of as many JavaScript community members as it can and turns the results into an interesting report on the state of the ecosystem β hereβs the results from 2024. If you have the time, fill it in, especially as they format it in a way where you can actually learn about stuff as you go.
Devographics
Please open Telegram to view this post
VIEW IN TELEGRAM
π€2β€1π₯1
CHALLENGE
class DataProcessor {
constructor(value) {
this.value = value;
}
transform(fn) {
return new DataProcessor(fn(this.value));
}
getValue() {
return this.value;
}
}
const multiply = x => x * 2;
const add = x => x + 10;
const square = x => x * x;
const result = new DataProcessor(5)
.transform(multiply)
.transform(add)
.transform(square)
.getValue();
console.log(result);
β€1
β€2π2π₯1