JavaScript: Class Constructor

class MyClass {
constructor(option) {
console.log(`Creating instance using ${option} option.`);
this.option = option;
}
}
const foo = new MyClass('speedy'); // logs: "Creating instance using speedy option"

--

--

Trusted Veteran | Compassionate. Aspiring. Resourceful.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store