Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // base.js
- 'use strict';
- export default class BaseClass {
- set job ( job ) {
- this._job = job;
- }
- get personData () {
- return {
- name: `${this._last}, ${this._first}`,
- job: this._job
- }
- }
- // classes.js
- 'use strict';
- import BaseClass from './base';
- export default class PersonClass extends BaseClass {
- constructor( first = 'John', last = 'Doe' ){
- super( );
- this._first = first;
- this._last = last;
- this._job = null;
- }
- }
- // app.js
- 'use strict';
- import PersonClass from './classes';
- import constant from 'lodash/utility/constant';
- const John = new PersonClass( undefined,'Hyland' );
- const Justin = new PersonClass( 'Justin','Hyland' );
- const Nathan = new PersonClass( 'Nathan','Hyland' );
- John.job = 'Father';
- Justin.job = 'Engineer';
- Nathan.job = 'Developer';
- const people = {
- john: constant(John.personData),
- justin: constant(Justin.personData),
- nathan: constant(Nathan.personData)
- };
- console.log( 'Johns info:', people.john() );
- console.log( 'Justins info:', people.justin() );
- console.log( 'Nathans info:', people.nathan() );
Advertisement
Add Comment
Please, Sign In to add comment