MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/javascript/comments/a6txtp/coming_from_python_to_js/ebz24wy/?context=9999
r/javascript • u/chroner • Dec 16 '18
const print = console.log
I found my safe space.
156 comments sorted by
View all comments
22
I actually kind of like this because I always manage a typo when I type 'console.log'. I get a lot of 'cosnole.log'. I think I'm much more consistent typing 'print'.
26 u/Earhacker Dec 16 '18 VS Code, Atom and the like usually have a snippet that autocompletes when you just type "log". 0 u/[deleted] Dec 16 '18 [deleted] 33 u/Earhacker Dec 16 '18 You could go to Menu -> Preferences -> User Snippets -> JavaScript and add this to the file:"Print to console": { "prefix": "print", "body": [ "console.log('$1');", "$2" ], "description": "Log output to console" }And now every time you type "print" in a JS file it will autocomplete to "console.log()" with your cursor between the brackets.Safe space safely restored! 0 u/[deleted] Dec 16 '18 [deleted] 16 u/Earhacker Dec 17 '18 for loops are for dirty Python casuals. Over here in JavaScript we use Array.prototype.forEach.(but sure, we use your fornum loop sometimes too) 4 u/mrbojingle Dec 17 '18 eww. map ftw! Unless you want to run print, then forEach away! 2 u/Earhacker Dec 17 '18 They’re not exactly interchangeable
26
VS Code, Atom and the like usually have a snippet that autocompletes when you just type "log".
0 u/[deleted] Dec 16 '18 [deleted] 33 u/Earhacker Dec 16 '18 You could go to Menu -> Preferences -> User Snippets -> JavaScript and add this to the file:"Print to console": { "prefix": "print", "body": [ "console.log('$1');", "$2" ], "description": "Log output to console" }And now every time you type "print" in a JS file it will autocomplete to "console.log()" with your cursor between the brackets.Safe space safely restored! 0 u/[deleted] Dec 16 '18 [deleted] 16 u/Earhacker Dec 17 '18 for loops are for dirty Python casuals. Over here in JavaScript we use Array.prototype.forEach.(but sure, we use your fornum loop sometimes too) 4 u/mrbojingle Dec 17 '18 eww. map ftw! Unless you want to run print, then forEach away! 2 u/Earhacker Dec 17 '18 They’re not exactly interchangeable
0
[deleted]
33 u/Earhacker Dec 16 '18 You could go to Menu -> Preferences -> User Snippets -> JavaScript and add this to the file:"Print to console": { "prefix": "print", "body": [ "console.log('$1');", "$2" ], "description": "Log output to console" }And now every time you type "print" in a JS file it will autocomplete to "console.log()" with your cursor between the brackets.Safe space safely restored! 0 u/[deleted] Dec 16 '18 [deleted] 16 u/Earhacker Dec 17 '18 for loops are for dirty Python casuals. Over here in JavaScript we use Array.prototype.forEach.(but sure, we use your fornum loop sometimes too) 4 u/mrbojingle Dec 17 '18 eww. map ftw! Unless you want to run print, then forEach away! 2 u/Earhacker Dec 17 '18 They’re not exactly interchangeable
33
You could go to Menu -> Preferences -> User Snippets -> JavaScript and add this to the file:
"Print to console": { "prefix": "print", "body": [ "console.log('$1');", "$2" ], "description": "Log output to console" }
And now every time you type "print" in a JS file it will autocomplete to "console.log()" with your cursor between the brackets.
Safe space safely restored!
0 u/[deleted] Dec 16 '18 [deleted] 16 u/Earhacker Dec 17 '18 for loops are for dirty Python casuals. Over here in JavaScript we use Array.prototype.forEach.(but sure, we use your fornum loop sometimes too) 4 u/mrbojingle Dec 17 '18 eww. map ftw! Unless you want to run print, then forEach away! 2 u/Earhacker Dec 17 '18 They’re not exactly interchangeable
16 u/Earhacker Dec 17 '18 for loops are for dirty Python casuals. Over here in JavaScript we use Array.prototype.forEach.(but sure, we use your fornum loop sometimes too) 4 u/mrbojingle Dec 17 '18 eww. map ftw! Unless you want to run print, then forEach away! 2 u/Earhacker Dec 17 '18 They’re not exactly interchangeable
16
for loops are for dirty Python casuals. Over here in JavaScript we use Array.prototype.forEach.
for
(but sure, we use your fornum loop sometimes too)
fornum
4 u/mrbojingle Dec 17 '18 eww. map ftw! Unless you want to run print, then forEach away! 2 u/Earhacker Dec 17 '18 They’re not exactly interchangeable
4
eww. map ftw! Unless you want to run print, then forEach away!
2 u/Earhacker Dec 17 '18 They’re not exactly interchangeable
2
They’re not exactly interchangeable
22
u/BloodAndTsundere Dec 16 '18
I actually kind of like this because I always manage a typo when I type 'console.log'. I get a lot of 'cosnole.log'. I think I'm much more consistent typing 'print'.