Guest User

Untitled

a guest
Dec 11th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. // Свойства функции используются для создания коллекции из функций
  2. var store = {
  3. nextId: 1,
  4.  
  5. cache: {},
  6.  
  7. add: function(fn) {
  8. if( !fn.id ) {
  9.  
  10. fn.id = this.nextId++;
  11. this.cache[fn.id] = fn;
  12.  
  13. console.log("Function was successfully added");
  14.  
  15. return true;
  16. }
  17.  
  18. console.log("This function was already added to store.");
  19. }
  20. };
  21.  
  22. function ninja() {}
  23.  
  24. store.add(ninja);
  25. store.add(ninja);
Add Comment
Please, Sign In to add comment