Using Classes

Unlike other popular computer languages—such as C# or Java—JavaScript does not have any built-in support for classes. In JavaScript, you do not distinguish between a type (a class) and an instance of that type (an object). Everything in JavaScript is an object.

The WinJS library includes extensions to JavaScript for creating classes. These methods are used extensively within the WinJS library itself. For example, all of the WinJS JavaScript controls are created using these methods. In this section, we discuss how you can define new classes by taking advantage of the methods in the WinJS library.

Using WinJS.Class.define()

In the WinJS library, new JavaScript classes are created by calling the WinJS.Class.define() method. This method ...

Get Windows® 8.1 Apps with HTML5 and JavaScript Unleashed 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.