Understanding function against method


Function: A function is a name associated with a chunk of code. Please note that functions are related to stacks. When you call a function, it’s frame is created on top of the stack. When the function finishes executing, it’s frame is popped off the stack & destroyed.

Method: A function that is triggered by a message is known as a method. Please note that method is related to Heap. You can find the method that is associated to a class on the Heap rather than stack.