jLinux

Untitled

Dec 27th, 2015
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // base.js
  2. 'use strict';
  3.  
  4. export default class BaseClass {
  5.     set job ( job ) {
  6.         this._job = job;
  7.     }
  8.  
  9.     get personData () {
  10.         return {
  11.             name: `${this._last}, ${this._first}`,
  12.         job: this._job
  13.     }
  14. }
  15.  
  16. // classes.js
  17. 'use strict';
  18.  
  19. import BaseClass from './base';
  20.  
  21. export default class PersonClass extends BaseClass {
  22.     constructor( first = 'John', last = 'Doe' ){
  23.         super( );
  24.  
  25.         this._first = first;
  26.         this._last  = last;
  27.         this._job   = null;
  28.     }
  29. }
  30.  
  31. // app.js
  32. 'use strict';
  33.  
  34. import PersonClass from './classes';
  35. import constant from 'lodash/utility/constant';
  36.  
  37. const John   = new PersonClass( undefined,'Hyland' );
  38. const Justin = new PersonClass( 'Justin','Hyland' );
  39. const Nathan = new PersonClass( 'Nathan','Hyland' );
  40.  
  41. John.job   = 'Father';
  42. Justin.job = 'Engineer';
  43. Nathan.job = 'Developer';
  44.  
  45. const people = {
  46.     john:   constant(John.personData),
  47.     justin: constant(Justin.personData),
  48.     nathan: constant(Nathan.personData)
  49. };
  50.  
  51. console.log( 'Johns info:',   people.john() );
  52. console.log( 'Justins info:', people.justin() );
  53. console.log( 'Nathans info:', people.nathan() );
Add Comment
Please, Sign In to add comment