DEV Community

VICTOR OMONDI
VICTOR OMONDI

Posted on

4 1

Classes In Python VS Javascript

Python:

class Person:
    def __init__(self, fname):
        self.firstname = fname


class User(Person):
    def createPost(self):
        print('Post created by', self.firstname)
Enter fullscreen mode Exit fullscreen mode

Javascript:

class Person {
    constructor(fname) {
        this.firstName = fname;
    }
}

class User extends Person {
    createPost() {
        console.log('Post created by', this.firstName);
    }
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more