Next: , Up: Interoperability [Contents]


4.1 Using GNU ease.js Classes Outside of ease.js

GNU ease.js is a prototype generator—it takes the class definition, applies its validations and conveniences, and generates a prototype and constructor that can be instantiated and used just as any other ECMAScript constructor/prototype. One thing to note immediately, as mentioned in the section Defining Classes, is that constructors generated by ease.js may be instantiated either with or without the new keyword:

 var Foo = Class( { /*...*/ } );
 // both of these are equivalent
 Foo();
 new Foo();

Figure 4.1: Constructors generated by ease.js may omit the new keyword

ease.js convention is to omit the keyword for more concise code that is more easily chained, but you should follow the coding conventions of the project that you are working on.

Part of the GNU Project

Copyright © 2011, 2012, 2013, 2014, 2015, 2016 Free Software Foundation, Inc.

"GNU Inside!" Page Fold licensed under CC-BY-SA 2.0; incorporates "A Big GNU Head".

The source code of this website is available in the website branch of the Git repository.

Authored by Mike Gerwitz

AltStyle によって変換されたページ (->オリジナル) /