Skip to content

Instantly share code, notes, and snippets.

@magnetikonline
Last active February 12, 2024 02:12
Show Gist options
  • Save magnetikonline/94f0d8e5b92824e94900289c1e0ef4b8 to your computer and use it in GitHub Desktop.
Save magnetikonline/94f0d8e5b92824e94900289c1e0ef4b8 to your computer and use it in GitHub Desktop.
Node.js strict mode enabled?

Node.js strict mode enabled?

A quick test, this relies on the fact that this will not exist and point to the global scope when running in strict mode.

console.log('strict:',(function() { return (this === undefined); })());

Tip

Strict mode is enabled by default within ES module enabled packages.

In package.json:

{
  "type": "module"
}

Related

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment