Guest User

Untitled

a guest
May 24th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. // Combining YWA and YWAT objects
  2. function YWAT(pid) {
  3. /* constructor code */
  4. }
  5.  
  6. YWAT.prototype = {
  7. /* prototype */
  8. };
  9.  
  10. YWAT.PID = 12345;
  11. ...
  12. YWAT.getTracker = function (pid) {
  13. /* assorted boilerplate */
  14. return new YWAT(pid);
  15. };
  16.  
  17. // Or namespacing
  18. YWA.Tracker = function (pid) {
  19. ...
  20. };
  21.  
  22. YWA.getTracker(pid) {
  23. /* assorted boilerplate */
  24. return new YWA.Tracker(pid);
  25. }
  26.  
  27. // Or if the class constructor needs to be private
  28. (function (win, doc, undef) {
  29. function Tracker(pid) {
  30. ...
  31. }
  32.  
  33. YWA = {
  34. ...
  35. getTracker: function (pid) {
  36. /* assorted boilerplate */
  37. return new Tracker(pid);
  38. }
  39. };
  40. })(window, document);
Add Comment
Please, Sign In to add comment