Ticker

6/recent/ticker-posts

LIGHTNING AND LWC INTERVIEW QUESTIONS



1. How to call a controller method in javascript?

Ans: var action=component.get("methodname")


2.what is the use of do init method?

Ans: It will be loaded on the loading of the lightning applications. It is pretty much similar to the constructor.


3. What is the use of attributes?

Ans: Attribute is like a variable. If you want to store the data then we should go with an attribute.


4. What is a bounded expression?

Ans: We will able to get the new value.

          Syntax : {!v.attribute name}


5. What is an unbounded expression?

Ans: we will not able to get the new value.

         Syntax: {#v.attributename}


6. What is the use of AuraEnabled annotation?

Ans: If you want to access the data in the lightning application then we should write AuraEnabled annotation

->we will not able to access the data in the lightning application without auraEnabled


7. What is the use of global action in the controller?

Ans: $A.enqueueAction(action)

It's used to execute the server-side logic


8. Can we write a void method in lightning?

Ans: No


9. How to get the response from callback?

Ans: reponse.getReturnValue()


10. How to get the state in the controller?

Ans: response.getState()


11. Why the helper method is a best practice in lightning?

Ans: It's used for reusability


12. What is reusability in lightning?

Ans: We will able to access the value from one method to another method.

          method1:function(component){

          var name='sfdcscenarios';

          this.method2(name);

          },

          method2:function(name){

          //reusability

          console.log('name from method1 is'+name);

          }


13. Does it happen in the controller?

No. It will happen in the helper


14.what framework lightning will follow?

Ans: aura framework


15. How many tags we have in lightning?

Ans: ui tags

         Lightning tags


16. What is exends="force:slds"?

Ans: It will acquire the properties of lightning design system?


17. What happens if you don't put exends=" force:slds" in lightning application?

Ans: It will look like a normal HTML file


18. What is v in attribute?

Ans: It's a value provider. If you want to access the value from the attribute then we will

use {!v.attrname} or{#v.attributename}


19. When we should go with unbounded expression?

Ans: If you are simply dealing with reading operation then we should go with the unbounded expression


20. does Reusability is possible in the controller?

Ans: No


21. What is the Lightning component bundle?

Ans: 

        Component

        Controller

        Helper

        Design

        SVG

        Documentation

        Style

        Renderer


22.what is renderer?

Ans: If you want to override the standard rendering mechanism in salesforce lightning then we should go with the renderer.


23.what are the events in salesforce lightning?

Ans: 

        Component Event

        Application Event

        System Events


24..Which interface should you use if you want to get the id of the record from the record Detail

page?

Ans: force:hasRecordId


25. can we call one component to another component?

Ans: Yes we can call


26.how to call lightning component in Visualforce Page?

Ans: 

<aura:application access="GLOBAL" extends="ltng:outApp">

<aura:dependency resource="c:FlipCard"/>

</aura:application>


*Add the <apex:includeLightning /> component to your Visualforce page.

*Reference a Lightning app that declares your component dependencies with $Lightning.use().

*Write a function that creates the component on the Visualforce page with

$Lightning.createComponent().


27.how to pass the parameters in the controller?

Ans: action.setParams


28. How to Navigate From One Lightning Component to Another Lightning Component?

Ans: "e.force:navigateToComponent"


29. How to go from one lightning page to another lightning page through a click?

Ans: var urlEvent = $A.get("e.force:navigateToURL");


30. Best practices for lightning?

Ans: Do not put so many console logs. 

Make the use of the Salesforce lightning design system for consistent UI design. 

Make the use of Lightning data services to avoid server calls for Dml operations. 

Use unbounded expressions if the data across components are not required to be in synch. 

Before you decide to use a third-party library in a Lightning component, you should reevaluate if you really need that library. DOM manipulation libraries (like jQuery) and UI libraries (like Bootstrap or jQuery UI) in particular may no longer be needed when working with the Lightning Component Framework.

When possible, use the (sprite-based) Lightning Design System icons (using <lightning:icon> and <lightning:buttonIcon>) instead of custom icons. 

Salesforce is slower for users who have debug mode enabled. So, do not enable in Production. 

When appropriate consider passing the data in different components(using attributes, events or methods) rather than retrieving the same data in different components. 

When making a call to the server limit the columns and rows of the result set. Only select the columns you need. 

Set a limit on the query and provide a paging mechanism if needed. Don’t return a huge number of rows at once. 

Consider combining several requests(actions) in a single composite request. 

Cache the data when possible. 

Caching the data at the client-side can significantly reduce the number of server round trips and improve the performance tips. A storable action is a server action whose response is stored in the in the client cache so that subsequent requests for the same server method with the same set of arguments can be accessed from that cache. 

Try to limit the number of event handlers in your Lightning component. As you can guess, multiple event handlers means your component would be busy in listening to event changes resulting in performance overload. 

Always try to use a component event instead of an application event, if possible. Component events can only be handled by components above them in the containment hierarchy so their usage is more localized to the components that need to know about them. Application events are best used for something that should be handled at the application level, such as navigating to a specific record. Application events allow communication between components that are in separate parts of the application and have no direct containment relationship.

Use helper methods.

To improve runtime performance, set @AuraEnabled(cacheable=true) to cache the method results on the client. To set cacheable=true, a method must only get data. It can’t mutate data.


31. Where we can use Lightning Components?

We can use Lightning Components in the following places:

Drag-and-drop Components in the Lightning App Builder and Community Builder.

Add Lightning Components to Lightning Pages.

Add Lightning Components to Lightning Experience Record Pages.

Launch a Lightning Component as a Quick Action

Override Standard Actions with Lightning Components

Create Stand-Alone Apps


32. Which interface should you use if you want your component to be available for all pages?

Ans: You can use the flexipage:availableForAllPageTypes interface.


33. Which interface should you use if you want to override a standard action?

Ans: You will need to use the Lightning:actionOverride interface.


34. Which interface should you use if you want your component to be available only on the record home page?

Ans: You will need to use the flexipage:availableForRecordHome interface.


35. Which interface should you use if you want your component to be used a tab?

Ans: You will need to use the force:appHostable interface.


36. Which interface should you use if you want your component to be used a quick action?

Ans: You will need to use the force: lightningQuickAction interface.


37. How can you call the controller method based on a component load?

Ans: "<aura:handler name="init" value="{!this}" action="{!c.doInitialization}"/


38. What are the component events?

Ans: Component events are events which are fired by child components and handled by the parent

component. We can make use of this event when we need to pass a value from a child

component to a parent component.


39. What are the application events?

Ans: Application events can be fired from any component and can be handled by any component.

They do not require any kind of relationship between the components, but these components

must be a part of a single application.

40. What is force:recordData, and what are its advantages?

Ans: force:recordData is a standard controller of a Lightning Component. We can perform an

operation such as creating a record, editing a record, deleting a record using force:recordData. If

we are using force:recordData, it identifies and eliminates the duplicate request going to the

server if they are requesting for the same record data (which in turn improves performance).


41. What are the phases in component events propagation?

Ans: There are two phases in component event propagation.

         Bubble Phase

         Capture Phase


42. What are the phases in application events propagation?

Ans: 

         Bubble Phase

         Capture Phase

         Default Phase


43. How do the bubble phase and the capture phase propagate?

Ans: Bubble phase: propagates from Bottom to Top.

         Capture phase: propagates from Top to Bottom.


44. What is Aura:method in the Salesforce Lightning component?

Ans: We can directly call a child component controller method from the parent component controller method using Aura:method. This method is used to pass value from the parent component controller to the child component controller.


45. What is Lightning:overlayLibrary in the Salesforce Lightning component?

Ans: To create a modal box we use Lightning:overlayLibrary.To use Lightning:overlayLibrary in component we need to include tag <lightning:overlayLibrary aura:id="overlayLib"/> in component, here aura:id is unique local id. Modal has header, body, and footer which are customizable.


46. what are the lightning webcomponent bundle?

Ans: LWC bundle contains an HTML file, a JavaScript file, and a metadata configuration file, and these files are created once we create a Lightning web component. We can also create a .cssfile for styling purpose and We can also create an SVG file for the purpose of displaying an icon.


47. What are the types of decorators in lightning web components?

Ans: We have 3 Decorators in Lightning Web Components.

1) @api

2) @track

3) @wire


48. Is there any limit on how many components to having in one Application?

Ans: There is no limit.


49. Is Lightning Components replacing Visualforce?

Ans: No.


50. What are the advantages of lightning?

Ans: The benefits include an out-of-the-box set of components, event-driven architecture, and a framework optimized for performance. 

Out-of-the-Box Component Set -: Comes with an out-of-the-box set of components to kick start building apps. You don’t have to spend your time optimizing your apps for different devices as the components take care of that for you.

Rich component ecosystem-: Create business-ready components and make them available in Salesforce1, Lightning Experience, and Communities.

Performance –: Uses a stateful client and stateless server architecture that relies on JavaScript on the client-side to manage UI, It intelligently utilizes your server, browser, devices, and network so you can focus on the logic and interactions of your apps.

Event-driven architecture -: Event-driven architecture for better decoupling between components

Faster development –: Empowers teams to work faster with out-of-the-box components that function seamlessly with desktop and mobile devices.

Device-aware and cross-browser compatibility –: Responsive design, supports the latest in browser technology such as HTML5, CSS3, and touch events.


51. How can we deploy components to production org?

Ans: We can deploy components by using managed packages, Force.com IDE, Force.com Migration Tool, or Change Sets.


52. How we can access Custom Label in Lightning?

Ans: Syntax : $A.get(“$Label.namespace.labelName”)


53. How we can use the component in the community builder?

Ans: Implements “forceCommunity:availableForAllPageTypes” interface on the component

Post a Comment

0 Comments