Function vs Method
In most of the place you will find method and function are use interchangeably but they have a key difference.
|Context and Association
|Standalone, can be called independently.
|Belongs to an object or a class, and is typically called on an instance of a class.
|Access to Data
|Generally does not have access to data stored in an object unless it is passed to the function.
|Has access to the data of the class and can modify the state of an object.
The key difference lies in their association with objects.
Methods are intrinsically linked to the objects of the classes they belong to and often manipulate the data within those objects, while functions are more independent and can be defined and used outside of the context of a class.