Usercould be 1 such class, where a user could have multiple attributes such as name, email, password, and also multiple "methods" (another word for functions that are part of a class) that perform functionality on specific user "instances". An "instance" is 1 instantiation of a class, e.g. a
Userinstance that represents Akira. 1 example of a method on the
Userclass could be
validatePassword, which might hash an input password and verify if it matches the relevant user's password.
user.getItemsmethod on a user retrieved with Sequelize are examples of attributes and methods in the Sequelize
Userclass that we define in our model file (with Sequelize helper functions).
Catis created the
__init__constructor method gets called (and the print function gets called). The constructor is an Object Oriented term that refers to a method that is called when an instance of the class is being created and is used to help set up the values inside of the instance.
cat2we are going to be calling the instance methods inside the instance. How do we refer to each Cat (i.e.,
cat2) itself? The
selfkeyword is used in Python to refer to the object from within the instance method. So here,
self.namerefers to the name inside the cat when we call
cat1.get_name()- "Kai" in one case and "Chee Kean" in the other- i.e., the
namevalue refers to that instance if we are calling the function for
greetingmethod could produce different results between instances of