subscribe our youtube channel popup

What’s wrong with my JavaScript Code

JavaScript is an essential part of programming on the Salesforce platform. However, since it is dynamic and loosely typed, it is prone to programmer errors. Common mistakes can lead to pull-out-your-hair issues and bad coding practices not only affect the performance, but the security of your apps and data as well.

In this session, you’ll look at an inefficient code sample riddled with bad practices, memory leaks and bugs. You’ll learn how to identify and fix each of them. You’ll walk away with an understanding of how to write better JavaScript code and apply a few best practices that improve your code quality and maintainability.

Here is the agenda:

  1. Evolution of JavaScript and Shorthand Syntax
  2. Common Mistakes
    1. Type Coercion
    2. Null vs undefined
    3. Incorrect references to “this”
    4. Data references and leaks
    5. Insecure Code
    6. Inefficient DOM Access
  3. ESLint

Evolution of JavaScript

Introducing Shorthand Syntax

Declaring an object, where the variable and object property name are the same

JavaScript Shorthand Syntax

String Concatenation

Anonymous Functions

Insecure Code

SOQL query exposed to the browser

Insecure Code LWC
  • Use APEX for business logic like making callouts and database operations.
  • Never trust the data coming from the browser/client.
  • Remember that minification is not a security feature.
  • Enforce proper scoping when using cookies.

ESLINT

  • Linting is a process of analyzing code for potential errors.
  • Enforces Secure Coding and Best Practices
  • Integrates as a plugin to VS Code.
  • Enforces Rules like
    • Disallow Assignment to undeclared variables
    • Require the use of === and !==
    • Disallow the use of alert, confirm, and prompt.
    • Disallow unused variables

Recording

What’s wrong with my JavaScript Code
Date     : Saturday, APR 04, 2020 10:00 AM EST (7:30 PM IST )
Speaker : Aditya Naag Topalli

Further Learning

If you are new in Salesforce. Please check our free Salesforce Admin and Salesforce Developer training. Subscribe to the channel if you haven’t already

Thanks,
Salesforce Apex Hours

Apex Hours
Apex Hours

Salesforce Apex Hours is a program of the community, for the community, and led by the community. It is a space where Salesforce experts across the globe share their expertise in various arenas with an intent to help the Ohana thrive! Join us and learn about the apex hours team.

Articles: 419

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *