11.5 static Methods

In this section, we continue to work our way through the Point Tracker web page’s Point class definition, with a focus on the getCount and distance methods. They’re static methods, which work a bit differently than regular methods.

In the previous section, we examined the Point class’s constructor. After the constructor comes the value method. It’s the same value method that we looked at in Section 11.3. It returns a Point object’s value in the form “(x, y).” Next is the getCount method….

getCount Method

As its name implies, the getCount method returns the count property (which holds the number of Point objects). For methods that return a property, it’s standard practice to use “get” as the first word in their names. ...

Get Web Programming with HTML5, CSS, and JavaScript now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.