Which of the following is a way to create a singleton object in JavaScript?

  • Using the Factory Pattern
  • Using the Prototype Pattern
  • Using the Singleton Pattern
  • Using the Module Pattern
A singleton object in JavaScript is typically created using the Module Pattern. The Module Pattern allows you to encapsulate code and create a single instance of an object, ensuring that only one instance of the object exists throughout your application. The other options (Factory, Prototype, and Singleton patterns) serve different purposes.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *