es6 call class methods from within same class

37,121

Use this

import blah from './blaha';

export default class myclass{
  constructor(con) {
    this.config = con;
  }

  async meth1(paramA) {
    //do_stuff...
  }

  meth2(paramB) {
     this.meth1()
  }
}
Share:
37,121
WeeniehuahuaXD
Author by

WeeniehuahuaXD

Full stack software engineer. Love X-Platform stuff but JS kinda became my life lol

Updated on March 28, 2020

Comments

  • WeeniehuahuaXD
    WeeniehuahuaXD about 4 years

    I'm trying to call a class method in my class form a neighboring method as shown in the example below.

    import blah from './blaha';
    
    export default class myclass{
      constructor(con) {
        this.config = con;
      }
    
      async meth1(paramA) {
        //do_stuff...
      }
    
        meth2(paramB) {
         //attempt to call meth1()
      }
    
    }
    

    I would like to call a method from within a different method using es6 class styles.