Now let’s say you want to add a filter feature that tracks which students are from different parts of the country, so you create a new fetch request that gets data from the server and updates the DOM when a location is filters. Simple enough.
But what happens when you want to include more practicality to your app? How about if you wanted to expand the amount of courses offered and track the students from other programs? After that, you want to give admin and teachers the ability to monitor the student’s grades throughout the program for each assignment.
With OOJS, we can think of organizing data into a collection of cells, each equipped with their own set of data and behaviors. Just like Ruby, OOJS has classes that objects can be created with data and behaviors. When a new object is created, for instance, a new student is enrolled in the program, they are created with a set of attributes, name, email, and address. This is called the constructor method of the class Student. A constructor is a set of data that is created when a new object is instantiated. Name, email, and address are passed in as arguments and assigned to ‘this’. ‘This’ refers to the object that it’s inside.
In Fig. 1, ‘this’ refers to the new student instance being created.