repl.it
JavaScript

No description

fork
loading
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
once = function (func) {
  var result;
  var once = false;

  return function () {
    if (!once) {
      result = func.apply(this, arguments);
      once = true;
    }
    return result;
  };
};

const startDatabase = () => {
	console.log('Database created...')
}

const initializeDatabase = once(startDatabase);
initializeDatabase();
// => Database created...
Native Browser JavaScript