Seydie

Factory function example

Nov 30th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const website = {
  2.     shownaam: function() {
  3.         return "test";
  4.     }
  5. };
  6.  
  7. const site_factory = (naam) => {
  8.     const o = Object.create(website);
  9.     return Object.assign(o, {name: naam});
  10. };
  11.  
  12. const Coolsite = site_factory("Coolsite");
  13. console.log(coolsite.shownaam());
Advertisement
Add Comment
Please, Sign In to add comment