DEV Community

Discussion on: Tricky JavaScript Questions

Collapse
 
tomeraitz profile image
Tomer Raitz

Thank you for the response. It's is very helpful. You right, The window object exists only in the browser (client-side). I wanted to show the basic concepts of javascript. The scope of node js it's a little bit different. You can create a global variable by doing global.length (not recommended) - but without it, I think this won't know what length is. if you that in node.js it will work:

global.length = 10;
function fn () {
  console.log (this.length);
}
fn();
Enter fullscreen mode Exit fullscreen mode