JavaScript Strict Mode Enforcement

In JavaScript, strict mode is enforced in modules but optional in regular programs. However, Lightning Web Security (LWS) and Lightning Locker implicitly enable JavaScript strict mode everywhere. You don’t need to specify "use strict" in your code. JavaScript strict mode makes code more secure, robust, and supportable.

When strict mode is enabled and unsafe actions are taken, JavaScript throws errors that would otherwise be suppressed. Examples of unsafe actions include assigning values to non-writable properties and using a variable that hasn’t been declared. Reporting these actions can catch situations when a variable name has been mistyped.

A few common stumbling points when using strict mode are:

For more information about JavaScript strict mode, see the Mozilla Developer Network.

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.