Skip to content

Instantly share code, notes, and snippets.

@MattyQ
Created February 11, 2023 01:53
Show Gist options
  • Save MattyQ/5f5cc31383dedfe0e9d1e5ea26f1f538 to your computer and use it in GitHub Desktop.
Save MattyQ/5f5cc31383dedfe0e9d1e5ea26f1f538 to your computer and use it in GitHub Desktop.
Implements a simple example class that includes a static private class. The static private class is used to construct objects when the global public class is instantiated.
"use strict";
/** Public class that uses a static private class as the constructor for the public class. */
class GlobalPublicClass {
/** Static private class that is only accessible within the scope of GlobalPublicClass. */
static #InternalPrivateClass = class {
/**
* Constructs the #InternalPrivateClass object.
*/
constructor() {
this.name = "example internal class";
}
}
/**
* Constructs an object using the static private class.
* @return {#InternalPrivateClass}
*/
constructor() {
return new GlobalPublicClass.#InternalPrivateClass();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment