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:
- Share JavaScript code between Lightning web components
- Use third-party libraries with Locker or Lightning Web Security
- Call APIs from JavaScript
- Dynamically Instantiate Components
For documentation on JavaScript functions, see the Mozilla Developer Network (MDN) JavaScript Reference.
To speed up your LWC development, it's helpful for you to be familiar with these JavaScript features.
- Arrays (Array.prototype.map, Array.prototype.filter)
- Arrow functions
- Classes
- Modules
- Objects (Object.keys, Object.values)
- Promises
- Variable declarations with
const
andlet
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.
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.