1

If there are two javascript methods A() and B() in same LWC component, is it possible to call method B() from A() where Function A() gets called with click of button? If not what can be the possible workaround for this?

2 Answers 2

5

Yes, use this to access other methods:

export default class CMD extends LightningElement {
  A() {
    this.B();
  }
  B() {
    // do something //
  }
}
0

When you have a parameter. Use this

export default class CMD extends LightningElement {
A() {
  var addition = 5+5;
    this.B(addition);
  }
  B(add) {
    console.log('Addition is : '+add);
  }
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .