Created
February 11, 2023 01:53
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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