loading...

Classes In Python VS Javascript

victoromondi1997 profile image VICTOR OMONDI ・1 min read

Python:

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


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

Javascript:

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

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

Discussion

pic
Editor guide