What is the output of the following? “`js function foo() { ‘use strict’; console.log(this); } foo(); “`

JavaScript Developer Hard

JavaScript Developer — Hard

What is the output of the following? “`js function foo() { ‘use strict’; console.log(this); } foo(); “`

Key points

  • In strict mode, `this` is `undefined` in functions
  • The function `foo` is called without any context, so `this` defaults to `undefined`
  • The `console.log(this)` statement will output `undefined`

Ready to go further?

Related questions