Method And Function

1.What is the different between method and function?

A method is on an object. (Tồn tại trên/trong một Object)

A function is independent of an object. (Độc lập với các Object)

2.Method and Function in programming languages

For C, there are only functions (because no OOP context in C)

For C++ it would depend on whether or not you’re in a class.

For Ruby, there are only methods, because almost anything in Ruby is Object and when you define a “function” not blong to any object, actually it still exist in an “global object” (feeling matrix movie).

For Js, existing both.

3.Reference

[1]https://stackoverflow.com/questions/155609/whats-the-difference-between-a-method-and-a-function