JavaScript

Every component must have a JavaScript file. JavaScript files in Lightning web components are ECMAScript 6 (ES6) modules.

In this section, you can learn how to:

For documentation on JavaScript functions, see the Mozilla Developer Network (MDN) JavaScript Reference.

JavaScript for Lightning Web Components 

To speed up your LWC development, it’s helpful for you to be familiar with these JavaScript features.

Many of our examples in lwc-recipes and in this developer guide now use async/await instead of promises. async/await helps you write code that’s more intuitive and resembles synchronous code. async/await is compatible with ordinary try/catch blocks around asynchronous code.

Note

LWC JavaScript Best Practices 

LWC is an abstraction layer on top of Web Component APIs that simplifies your developer experience and improves productivity. To learn about LWC best practices, see Best Practices for Development with Lightning Web Components.

Release Preview

This release is in preview. Features described here don't become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can't guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.