
50 LWC Lightning Web Component Interview Questions
50 Scenario based exclusive Salesforce Lightning Interview Questions with detailed Answers 2021 by CRS info Solutions with code snippets and unique answers.

- What are the type of events into Salesforce Lightning component
- Application Event(Salesforce Document)
- Component Event
- System Event(Salesforce Document)
- What is the basic difference between Application Event and Component Event
- The major difference between application and component event is that component event is used in child to parent components and application event can be used throughout the application.
- Which interface needs to be implemented so that you can use lightning components as quick action.
- force:lightningQuickAction
- Which interface needs to be implemented so that you can use the lightning component as Tab like custom object and VF page.
- force:appHostable
- Can we use Lightning Components in the VF page?
- Yes, using lightning out functionality of the salesforce lightning component.
- How can we call the child component controller method from the parent component controller method?
- Yes, we can call using aura methods.
- Salesforce Document
- What are the different Lightning component bundles?
- Component
- Controller
- Helper
- Style
- Document
- Design
- SVG
- Renderer
- More Info Here(Salesforce Document)

- What is the use of Document and Renderer in lightning components?
- Document: – A description, sample code, and one or multiple references to example components
- Client-side renderer to override default rendering for a component.
- How to ensure FLS while working with Lightning Component?
- Lightning Data Services already ensures Field Level Security and we can also use into the Apex using isAccessible, isCreateable, isDeleteable, isCreateable and etc methods of Schema class.
- Can we use fieldSet in the lightning component?
- Yes. We can use Lightning:RecordForm and provide the list of the Fields in fields attribute. For more information Refer Here
- How to navigate from one component to another component.
- We can use force:navigateToComponent
- OR we can use lightning:navigation
- Can we use PageReference in Lightning Component?
- Yes
- How to call the Parent Component method from the child component without using events?
- Yes. By using aura:action but the recommended way is to use Component Event
- Can we use LWC inside Aura?
- Yes. We can use
- Can we use Aura Inside LWC?
- No. We can only use LWC inside Aura but not vice versa
- Is Lightning an MVC framework ?
- No, it’s a component-based framework.
- Which parts of Lightning Components are server-side and which are client-side ?
- Lightning Components use JavaScript on the client side and Apex on the server side.
- Is there any limit on how many components to have in one Application ?
- No
- Is Lightning Components replacing Visualforce ?
- No
- What is Aura? Why do we use the aura: namespace in the code ?
- Aura is the open source technology that powers Lightning Components. The aura: namespace contains all of the basic building blocks for defining components and applications.
- What is the difference between Visualforce Components and Lightning Components ?
- Visualforce components are page-centric and most of the work is done on the server. Lightning is designed from the component up, rather than having the concept of a page as its fundamental unit. Lightning Components are client-side centric, which makes them more dynamic and mobile friendly.
- Can we integrate Lightning components with another framework, such as Angular?
- Yes. we can include the working 3rd party code inside a Visualforce Page, embed the Visualforce Page inside a Lightning Component. This Lightning Component can be used as any other Lightning Component in various environments.
- What is use of @AuraEnabled annotation
- @AuraEnabled method is used to make any Apex Method for either Aura or LWC Component. @AuraEnabled Method must be static in nature.
- What If I try to make any DML inside a method which is having @AuraEnabled(cacheable=true)?
- If you try to make a DML inside the method then you will read only errors. cacheable=true makes the method read only.
- How to Create a Component Dynamically?
- Use $A.createComponent for creating the dynamic component see below code snippet.
- Component Code
<!--c:createComponent-->
<aura:component>
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<p>Dynamically created button</p>
{!v.body}
</aura:component>
JS Code
/*createComponentController.js*/
({
doInit : function(cmp) {
$A.createComponent(
"lightning:button",
{
"aura:id": "findableAuraId",
"label": "Press Me",
"onclick": cmp.getReference("c.handlePress")
},
function(newButton, status, errorMessage){
//Add the new button to the body array
if (status === "SUCCESS") {
var body = cmp.get("v.body");
body.push(newButton);
cmp.set("v.body", body);
}
else if (status === "INCOMPLETE") {
console.log("No response from server or client is offline.")
// Show offline error
}
else if (status === "ERROR") {
console.log("Error: " + errorMessage);
// Show error message
}
}
);
},
handlePress : function(cmp) {
// Find the button by the aura:id value
console.log("button: " + cmp.find("findableAuraId"));
console.log("button pressed");
}
})
- Can we navigate to one component from another component?
- Yes. we can navigate for this we can use lightning:navigation.
- Below is the code for the same
({
doInit : function(component, event, helper) {
},
navigate : function(component, event, helper) {
var nagigateLightning = component.find('navigate');
var pageReference = {
type: 'standard__objectPage',
attributes: {
objectApiName: 'Account',
actionName: 'list'
},
state: {
filterName: 'MyAccounts'
}
};
nagigateLightning.navigate(pageReference);
}
})
- Which Interface is used to make a component available inside Salesforce Digital Experience?
Ans: forceCommunity:availableForAllPageTypes
Part – 2 | 50 LWC Lightning Web Component Interview Questions
Comments are closed.