As simple as this:
window = 'Hello world';
console.log(window);
I am pretty sure this should work and post in console 'Hello world', but it doesn't.
No. In sloppy mode, it'll fail silently. In strict mode, you'll see an explicit error.
'use strict';
window = 'Hello world';
console.log(window);
You can't reassign it. I think the best you could do is to create a new variable named window not on the top level.
(() => {
const window = 'Hello world';
console.log(window);
})();