1. Computing
In JavaScript all functions are methods. The difference between a function and a method in JavaScript is mostly a matter of terminology. If you are using a procedural approach you will call them functions and if you are using an object oriented approach then you'll call them methods. While functions and methods are actually different from one another, in JavaScript there is no real distinction because all stand alone functions are really methods of the window object. In this eight "Learn Modern JavaScript" tutorial we look at the main ways to define a function or method.

Functions and Methods
Comments
July 18, 2011 at 4:06 am
(1) Emiel Vermeulen says:

Thanks Stephen, I often take a look at your website if something is not clear about javascript.

One remark on the subject “all functions are methods”. Does this also apply to inner functions (declared by “var”) ?

Greetings, Emiel

July 19, 2011 at 9:56 pm
(2) Stephen says:

Everything declared using var that are outside of a function are properties and methods of the window object.

Everything defined using var inside a function are properties and methods of that object (since all functions are also objects).

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

©2014 About.com. All rights reserved.