
1. **What is a Lightning Web Component (LWC)?**
Lightning Web Component is a Salesforce programming model that uses modern web standards to build components for the Salesforce Lightning Platform.
2. **What are the key features of Lightning Web Components?**
Key features are reusability, encapsulation, performance optimization, and compatibility with modern web standards.
3. **How do you pass data from a parent component to a child component in LWC?**
Pass data using properties annotated with the `@api` decorator in the child component.
4. **How can you handle events in LWC?**
Handle events using the `@wire` decorator to bind a component’s property to a value from an Apex method.
5. **What is the purpose of the `@wire` decorator in LWC?**
The `@wire` decorator wires a component’s property to a data source, like an Apex method or a field on a record.
6. **What is the role of the Lightning Data Service (LDS) in LWC?**
Lightning Data Service provides a standard way to access and manipulate Salesforce data in Lightning Components, including LWC.
7. **How do you make an HTTP callout from a Lightning Web Component?**
Use the `fetch` API to make HTTP callouts. Import the `fetch` method for sending requests to external services.
8. **What is the use of the `@track` decorator in LWC?**
The `@track` decorator tracks changes to properties, allowing the component to rerender when those properties change.
9. **How do you handle errors in Lightning Web Components?**
Use try-catch blocks to catch and handle errors gracefully, and display error messages to users.
10. **What is the difference between `lightning-card` and `lightning-layout` components in LWC?**
`lightning-card` provides a styled container for content, while `lightning-layout` creates layouts with multiple regions.
11. **Explain the concept of shadow DOM in LWC.**
Shadow DOM encapsulates a component’s styles and structure, preventing CSS conflicts with other components on the page.
12. **What is the role of the `wire` service in LWC?**
The `wire` service provides reactive data binding, allowing data to be gotten and updated from a data source without boilerplate code.
13. **How do you handle user interactions in LWC?**
Use event handlers in the template to listen to user interactions and call methods in the component’s JavaScript.
14. **What is the purpose of the `api` property in LWC?**
The `api` property exposes properties and methods in a Lightning Web Component for use by parent components or external code.
15. **What is the difference between imperative and reactive Apex methods in LWC?**
Imperative methods use `@wire` to fetch data when needed, while reactive methods use the `@wire` service to update data automatically when it changes.
16. **How can you make a Lightning Web Component available for use in the Salesforce App Builder?**
Define a custom component in the `meta.xml` file of your LWC and set the `isExposed` attribute to `true`.
17. **What is the purpose of the `lightning-record-edit-form` component in LWC?**
`lightning-record-edit-form` creates, views, or edits a record’s fields using the Salesforce Lightning Data Service.
18. **How can you communicate between sibling components in LWC?**
Use custom events and properties defined in a common parent component for communication between sibling components.
19. **What is the role of the `lightning/navigation` module in LWC?**
The `lightning/navigation` module navigates users to different pages within Salesforce, such as records, lists, or custom pages.
20. **How do you unit test a Lightning Web Component?**
Write unit tests for LWC using Jest framework, supported by Salesforce. Test components, properties, and methods using Jest functions.