Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
// Singleton: module state is shared let instance = null; export function getInstance() { if (!instance) instance = new Store(); return instance; } // Factory: creates new instances export function createLogger(prefix) { return { log: (msg) => console.log(`[${prefix}] ${msg}`) }; } // Service: pure functions, no state export const mathService = { add: (a, b) => a + b, multiply: (a, b) => a * b, };
Result
Open