javascript - global scope in chrome and node.js -


when enter code console.log(this); in chrome dev tools, displays:

window {stop: function, open: function, alert: function, confirm: function, prompt: function…} 

but when execute same code in node.js (v6.11.1) displays:

{} 

shouldn't display information global object?

(said code thing executed, not part of program.)

in top-level code in node module, this equivalent module.exports. that's empty object see. example:

module.exports.a = 'test'; console.log(this); // 'test' 

in browsers, without using "use strict"-directive, this refers global object (window).


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -