Just like reactJS and angularJS are used for web technology similarly LWC framework is used for Salesforce front-end development.
VAR, LET and CONST
LET – Let is block scoped, it can be updated but not re-declared inside the same block and it solves hoisting issues.
CONST – Const is also block-scoped, it can neither be updated nor re-declared inside the same block and it solves hoisting issues as well.
Don't forget to check out: Learn About Salesforce Lightning Web Components
Arrow function allows us to write shorter function syntax. In regular functions, this keyword represented the object that is called the function, which could be the window, the document, or whatever. With arrow functions, this keyword always represents the object that defined the arrow function.
The operator’s shape is three consecutive dots and is written as:
Usages of the spread operator:
- Expanding Arrays – content get expanded and thrown out of array.
- Expanding String – convert string into list of array.
- Combining Arrays – combine array or add value to array.
- Combining Object – combine object or add value to object.
Destructuring is a special syntax that allows us to “unpack” arrays or objects into a bunch of variables, as sometimes that’s more convenient.
Export and Import JS modules
Exporting – To export, we use the export keyword.
Different ways of exporting:
- Export member individually
- Export together
- Export with Alias
- Default export
Importing – To import use the import keyword, members to be imported in curly brackets and then the location of modules relative to the current file.
Different ways of importing:
- Importing with alias
- Importing all exported members
- Imported module with a default member
Check out another amazing blog by Bhawana here: Data Manipulation and Error Handling in Salesforce
This method returns the first child element that matches a specified CSS selector of an element.
This method returns a collection of an element’s child elements that match a specified CSS selector, as a static NodeList object.
Don’t use ID selectors with query selectors and don’t use the window or document global properties to query for DOM elements.
The fetch API is a simple interface for fetching resources. Fetch makes it easier to make web requests and handle responses than with the older XMLHttpRequest which often requires additional logic.