Posted By

Pjotor on 11/26/15


Tagged

template skeleton boilerplate


Versions (?)

JS Component skeleton


 / Published in: JavaScript
 

URL: http://pjotor.com

A quick boilerplate/skeleton for js components based on parasitic inheritance and with private functions.

(also has a vanilla version of $.extend, just to keep it framework free)

  1. function extend() {
  2. var extended = {}, key, prop, argument;
  3. for(key in arguments) {
  4. argument = arguments[key];
  5. for (prop in argument)
  6. if (Object.prototype.hasOwnProperty.call(argument, prop))
  7. extended[prop] = argument[prop];
  8. }
  9. return extended;
  10. };
  11.  
  12. function Component(settings) {
  13. settings = extend(true, {
  14.  
  15. }, settings || {});
  16.  
  17. var that = this;
  18.  
  19. function init() {
  20. return that;
  21. }
  22.  
  23. //Public functions
  24. // this.public_function_name = publicFunction
  25.  
  26. return init();
  27. }
  28.  
  29. var component = new Component();

Report this snippet  

You need to login to post a comment.