0

Using 'this' in strict mode

Why does this returns undefined while using strict mode? 'use strict'; function test() { console.log(this) } test()

2nd Aug 2021, 2:32 PM
ŠœŠ³. ŠšŠ½Š°ŠæšŸŒ 
ŠœŠ³. ŠšŠ½Š°ŠæšŸŒ  - avatar
2 Answers
+ 1
this represents current object but you don't have any object in strict mode. If you comment that line then current object would be 'window'
2nd Aug 2021, 2:49 PM
AĶ¢J
AĶ¢J - avatar
+ 1
Oh yes! I didn't thought about it..
2nd Aug 2021, 3:26 PM
ŠœŠ³. ŠšŠ½Š°ŠæšŸŒ 
ŠœŠ³. ŠšŠ½Š°ŠæšŸŒ  - avatar