MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/javascript/comments/a6txtp/coming_from_python_to_js/ebxypu7/?context=3
r/javascript • u/chroner • Dec 16 '18
const print = console.log
I found my safe space.
156 comments sorted by
View all comments
20
you can go even further: global.print = console.log even though it's probably not the best idea to pollute your global ;-)
global.print = console.log
10 u/[deleted] Dec 16 '18 ...where is the global? 19 u/joelangeway Dec 16 '18 Iirc that works in node.js like window works in the browser, in that it’s synonymous with the global scope. 4 u/[deleted] Dec 17 '18 Ah right! 6 u/nickbreaton Dec 17 '18 If you're interested, there is an ECMAScript proposal to add globalThis so the same variable can be used for both node and the browser (or whatever JS environment you're in).https://github.com/tc39/proposal-global 1 u/baubleglue Dec 17 '18 global || global = window; 6 u/Rezistik Dec 16 '18 In Node. Attach it to the window on the browser. 2 u/bart2019 Dec 17 '18 global = window;
10
...where is the global?
19 u/joelangeway Dec 16 '18 Iirc that works in node.js like window works in the browser, in that it’s synonymous with the global scope. 4 u/[deleted] Dec 17 '18 Ah right! 6 u/nickbreaton Dec 17 '18 If you're interested, there is an ECMAScript proposal to add globalThis so the same variable can be used for both node and the browser (or whatever JS environment you're in).https://github.com/tc39/proposal-global 1 u/baubleglue Dec 17 '18 global || global = window; 6 u/Rezistik Dec 16 '18 In Node. Attach it to the window on the browser. 2 u/bart2019 Dec 17 '18 global = window;
19
Iirc that works in node.js like window works in the browser, in that it’s synonymous with the global scope.
window
4 u/[deleted] Dec 17 '18 Ah right! 6 u/nickbreaton Dec 17 '18 If you're interested, there is an ECMAScript proposal to add globalThis so the same variable can be used for both node and the browser (or whatever JS environment you're in).https://github.com/tc39/proposal-global 1 u/baubleglue Dec 17 '18 global || global = window;
4
Ah right!
6
If you're interested, there is an ECMAScript proposal to add globalThis so the same variable can be used for both node and the browser (or whatever JS environment you're in).
globalThis
https://github.com/tc39/proposal-global
1
global || global = window;
In Node. Attach it to the window on the browser.
2 u/bart2019 Dec 17 '18 global = window;
2
global = window;
20
u/Capaj Dec 16 '18
you can go even further:
global.print = console.logeven though it's probably not the best idea to pollute your global ;-)