Skip to main content

Command Palette

Search for a command to run...

How to define a class with properties and methods in javascript.?

Published
1 min readView as Markdown
class Car {
    constructor(model, name) {
        this.model = model;
        this.name = name;
    }
    start() {
        console.log("benz car")
    }
    stop() {
        console.log("AFTER 400 KILOMETERS")
    }
}

carName = new Car()
carName.start(588, 'sportedition')
carName.stop(450, 'sportedition')

More from this blog

Chowhan's blog

29 posts

A Passionate software developer