Posts

Showing posts from October, 2020

Understanding Var, Let, and Const in JavaScript for Salesforce Lightning Developers

As a Salesforce Lightning Developer, mastering JavaScript is essential, especially when dealing with variable declarations. ES6 introduced two new ways to create variables: let and const . Before diving into the differences between var , let , and const , let's cover some prerequisites: variable declarations vs. initialization, scope, and hoisting. Remember, const signals that the identifier won’t be reassigned, while let indicates that the variable may be reassigned. JavaScript Var In JavaScript, a variable can hold a value that can vary over time. The var keyword is used to declare a variable. A variable must have a unique name, and var is function-scoped. Example of var var temp = 'Hello' ; console . log ( window . temp ); // Output: 'Hello' var temp = 'Hello Code' ; console . log ( window . temp ); // Output: 'Hello Code' In this example, we see that var allows us to redeclare the variable temp , which overwrites the previous value....

Easy Steps to Create a Lightning Web Component Using VS Code

Easy Steps to Create a Lightning Web Component Using VS Code Follow these simple steps to create a Lightning Web Component (LWC) using Visual Studio Code. Step 1: Right-click on the LWC Folder Locate the LWC folder in your project structure and right-click on it to begin creating a new component. Step 2: Enter Your Desired Lightning Web Component Name Provide a meaningful name for your Lightning Web Component. Step 3: Accept Default LWC Path Enter the LWC name and accept the default path: force-app/main/default/lwc . Step 4: Update Your Component HTML Code Replace the content of your component's HTML file with the following code: < template > < lightning-card > < lightning-input type = "number" label = "Number of Employees" value = {numberOfEmployees} onchange = {handleChange} > </ lightning-input > < lightning-button label = "Reset...