in classes, you have a few extra features that allow you to have more performance than the object method:
bark()
method. It only references that to a certain place in the memory. BUT in the object method, you declare the method and variables within the loop all over again, reducing performance.new Dog();
) it will only declare for once and will be referred to the cached value or method, unless your class uses a dynamic value for the constructor. but in objects, you are redeclaring the methods 1000000 times. but it's declared once in classthese are the main concepts that classes are faster in this scenario