Facebook Pixel

What is this in a regular function under strict mode?

undefined. In sloppy mode, this defaults to the global object (window in browsers). Strict mode removes this default, so calling a function without a receiver gives this as undefined.

Verify This Answer

Cross-check this information using these trusted sources:

More FAQs in Hoisting in Strict Mode JavaScript

No. Hoisting still happens. var is hoisted with undefined, function declarations with their full body, and let/const sit in the TDZ. Strict mode does not change the hoisting mechanism itself.

It makes related bugs visible. Assigning to an undeclared variable throws ReferenceError instead of creating a global. this is undefined in regular functions instead of the global object. Duplicate parameter names throw.

Yes. Any file with import or export is automatically in strict mode. You do not need 'use strict'. Top-level this is undefined in modules, not the global object.

Still have questions?

Browse all our FAQs or reach out to our support team

Want to upskill yourself?

Our courses are taking a Coffee break, but your curiosity shouldn't. Stay engaged with namastedev linkedin, youtube, discord and other resources while you wait.

0
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.