window:
Open the console and type window.
The total size (seen and not seen). This is a window calculation, not the viewport but it can help (ie if you have element positioned absolutely outside, the innerwidth will be greater than the viewport.
The outside Width takes the whole window browser width
console.log("innerWidth: "+window.innerWidth)
console.log("innerHeight: "+window.innerHeight)
To test if the script is running in the browser or in node, you would test if you see the window and document variable
Example:
if ( typeof (window) !== "undefined" && window.document !== undefined ) {
console.log("I'm running in the browser");
} else {
console.log("I'm not running in the browser, therefore I'm running in Node");
}