Difference between method and function? -introduction to objects


What is the difference between a function and a method? functionally, don't they do the same thing?


Not every function is a method, but every method is a function.
Method is a function that belongs to certain objects/classes.
For example: toUpperCase() in JavaScript is a method that belongs to String - you can use it on any string.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.