Functions
Throughout this series we have dealt with a number of JavaScript's methods. Functions and methods, for all practical purposes, are the same thing. The name method is often used in conjunction with objects (thus used primarily with object-oriented languages), whereas the name function is most often employed in reference to standalone routines and procedural languages. It might be noted that functions are also referred to as subs, short for subroutines, in some languages such as Visual Basic and Perl. Technically speaking, there is a difference between a function and subroutine - functions return values, but subs do not (more on returning values later).
JavaScript, which is neither strictly object oriented nor strictly procedural, has incorporated both words into its parlance. The distinction in JavaScript is that 'method' generally refers to routines that are built into the JavaScript language, whereas 'function' generally refers to user-defined subroutines. Although any of the terms can be used interchangeably with a degree of intelligibility, most programmers recognise the distinctions outlined above.