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 Respuestas
+ 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