11.3 Classes, Constructors, Properties, new
Operator, Methods
Class Syntax
At a bare minimum, to implement a class, you need a class heading and a class body, and within the class body, you need a constructor and at least one method. To explain these things, we’ll present a class that defines a point with x
and y
properties for the point’s x and y coordinate positions. In FIGURE 11.2, note the class heading, which uses the word class
, followed by a name that describes what the class represents. In this case, the class represents a point, so Point
is the perfect name.
Constructor ...
Get Web Programming with HTML5, CSS, and JavaScript now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.