Debugging and Troubleshooting Lightning components Salesforce

JavaScript Is Case-Sensitive. If the API name of your object is Expense__c and a field is Amount__c, and you try to reference it with expense__c.amount__c (which works in Visualforce), it’s going to fail in JavaScript.

JSON.stringify() gives you a human-readable representation of even complex structured data. The console.log() command outputs a string in your browser’s JavaScript console.

JavaScript Controller in Lightning

1. This isn’t a class. It’s a JSON object containing a map of name:value pairs. It can contain only action handlers, which you’ll never invoke directly.

2. Your action handlers are declared as anonymous functions assigned to the action name (here, myAction and anotherAction). Your functions can accept up to three parameters, and only these parameters (component, event, and helper though you can name them differently). The framework supplies them when it calls the handler.

3. Most importantly, you separate your name:value pairs with a comma.

Handling Server-Side Errors

If your Apex code encounters an error, you can create and throw an AuraHandledException. Catching other exceptions, such as a DML exception, and rethrowing them as an AuraHandledException also results in much better experience on the client side.