Suppose there is some func function that performs an action on an obj object (DOM node), for example, attaches a child to it.
Initially, I solved the problem through a stand-alone function of the form func(obj, param) but then I decided that it would be more convenient if I did this as an object method and hooked it как obj.func(param) , but as I understood, declare function as a method in advance, in order to "cling" it to any object you don’t want, you need to attach a method to an object in advance if you want to use it:
obj: { func = function(param) { ... } } Why then do we need object methods? It looks like extra lines of code and extra space in memory.