r/javascript • • Dec 16 '18

Coming from Python to JS NSFW

const print = console.log

I found my safe space.

607 Upvotes

156 comments sorted by

View all comments

Show parent comments

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