DEV Community

VICTOR OMONDI
VICTOR OMONDI

Posted on

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)