Interview Questions – Lightning Framework – Part 2 – Inheritance

Interview Questions – Lightning Framework – Part 2 – Inheritance

9. What are different ways to call a javascript controller method?

Javascript Controller method can be called via:

  • By browser events like onclick, onchange etc
  • By Aura handlers of lifecycle events init handler, render handler
  • By Aura handlers of component and application events
  • By Aura Method

Read Also – Interview Questions – Lightning Framework – Part 1

10. How many parameters are there in a javascript controller method?

There are three parameters that a javascript controller method accept.

  • Component – Component or markup file reference
  • Event – It has all the properties of the event which fired this method
  • Helper – Helper file reference

These parameters are supplied by the framework itself and does not need to be passed explicitly.

11. Can we call one javascript controller method from other one?

No, javascript controller method can only be called by component markup.

12. Can we call one helper method from other helper method?

Yes, Helper file methods can be called from controller methods, other helper methods or from renderer file methods as well. Helper file is designed to put reusable code hence this code can be called from all javascript resource files.

13. What are different events fired during component rendering lifecycle?

During component rendering, there are several events which gets fired.

  • Init event – The component service that constructs the components fires the init event to signal that initialization has completed.
  • Render event – This event is called when component starts rendering. You can override this either by handling this event, or by creating custom renderer resource file.
  • After render – This event is called once rendering is completed.

Read Also: Code By Code – LWC – Chapter 1 – Why Lightning Web Components?

14. What is inheritance in Lightning framework?

Lightning framework allows you to extend another component. When a component extends another component, we refer to sub and super components in the inheritance hierarchy. This inherits super components properties and make them available to sub component.

15. What is inherited?

When one component extends another, it inherits super component’s attributes, events, controller and helper. You can use all these properties in your sub component.

16. What are the general steps to implement inheritance?

To implement inheritance, you need to complete below steps:

  • Create a parent component and make it extensible. This will allow your component to be inherited by other components.
  • Create another component and extend first component.

I hope these questions would help you in refreshing your concepts and clearing an interview. Keep reading more questions in next intreview posts.

Read Also

Manish Choudhari

I am a certified Salesforce Application & System Architect and Developer working on Salesforce Technology since 2014. Currently, I have 14 Salesforce certifications along with OCPJP (Oracle Certified Profession JavaSE6 Programmer) working in Hyderabad as a Technical Engineer. Writing technical blogs, learning new technologies and frameworks and sharing knowledge is my hobby.

This Post Has 4 Comments

  1. Hi Manish,

    For Question#11, I did some research on internet. It allows to call one Javascript controller method from another one. Here is the command – $A.enqueueAction(component.get(‘c.controllerMethod’));
    Let me know if I am missing something here


  2. Hi Manish, as you have shown in your lightning tutorial video – I created the toggle button but it does not seem to work properly. I have written the same code and also tried to debug it but no result. Can you please help me with that

Leave a Reply

Close Menu