C3 AI Documentation Home

Implementing JavaScript Methods

This topic contains JavaScript-specific nuances related to implementing methods using the C3 AI Type System. If you are not familiar with the general concept, refer to the topic methods.

Interfacing with c3

Within an implementation file for a Type, every Type declared in your package is available through a global reference. The only exception to this rule is if there are namespace conflicts with built-in JavaScript classes/functions. In that case, you would need to reference the Type using the c3 global variable.

These Types can be instantiated, and fields/methods can be accessed from instances of a Type.

For example:

JavaScript
function someFunc() {
    objInst = Obj.make() // invoke static method `Obj#make` to make an `Obj` instance
}

The this keyword

The this keyword has special meaning in C3 AI JavaScript methods. In the context of C3 AI member methods, this is the Type instance on which the member method was invoked. In the context of C3 AI static (non-member) methods, this is the Type upon which the method was invoked.

Was this page helpful?