göre this explanation in MDN için:`küresel bağlamda ve işlev içinde this`
küresel bağlamda- fonksiyonu doğrudan tekrar kesilmesi,
this
küresel nesne işlev bağlamında - değinmektedir
: aşağıdaki, henüz dünya nesnesininvar globalThis = this; function a() { console.log(typeof this); console.log(typeof globalThis); console.log('is this the global object? '+(globalThis===this)); } a();
değinmektedir dosyasında foo.js
yerleştirilen 210
... üretir: bir modülde yazmak ne olursa olsun kod
node.js yılında$ nodejs foo.js
object
object
is this the global object? false
deneyin 'console.log (bu) eklemek gibi gerçek küresel nesne başvurmak için,
global
object kullanabilirsiniz; – mplungjan