Live data from Hacker News

A Modern JavaScript Tutorial

javascript.info

21–30 of 299 posts

Re: A Modern JavaScript Tutorial

#21

> According to your browser language headers, you know Chinese. Please help to translate the tutorial into your language! Thank you! I'm curious. How are my language preferences exposed through HTTP headers? I think this was a charming way to request volunteers for translation, but I was a bit taken aback.

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Ac...

Re: A Modern JavaScript Tutorial

#22

The ninja code section is pure sarcasm, right? I'm not sure now which sections are and aren't.

Interestingly Golang encourages one letter variable names and it's not sarcasm this time : https://github.com/golang/go/wiki/CodeReviewComments#variabl...

Golang's landscape is full of one letter variables and abbreviations and it's not great.

Re: A Modern JavaScript Tutorial

#23

> According to your browser language headers, you know Chinese. Please help to translate the tutorial into your language! Thank you! I'm curious. How are my language preferences exposed through HTTP headers? I think this was a charming way to request volunteers for translation, but I was a bit taken aback.

The Accept-Language HTTP request header is my guess

Re: A Modern JavaScript Tutorial

#24

> According to your browser language headers, you know Chinese. Please help to translate the tutorial into your language! Thank you! I'm curious. How are my language preferences exposed through HTTP headers? I think this was a charming way to request volunteers for translation, but I was a bit taken aback.

Is your next thought after having your curiosity piqued not, "I should look at what headers my browser is sending", or "I should type 'browser language headers' into a search engine"? I'm trying to understand what sort of things lead people instead to think, "I should type a question about 'browser language headers' into a comment box on an off-topic thread, wait for a response, and then go back and check what the replies say."

Re: A Modern JavaScript Tutorial

#25
post #10

The ninja code section is pure sarcasm, right? I'm not sure now which sections are and aren't.

That page has an 'irony warning' so just watch out for those on other pages! It might just be my sense of humour (I'm the sort of person that doesn't need an '/s' tag and feels that it shouldn't be necessary if you told the joke properly ), but it was pretty obvious to me even without the irony warning that the page was intended as a joke. It looks like it was heavily inspired by the classic 'Tao of Programming' [0].…

I am with you on not wanting or needing to see /s ... but on a tutorial, where people actually struggle to understand anything at first read, using unmarked irony is maybe not the most helpful for them.

Oh and a second thought on /s. For some time I only got my news through satire sites like the onion. And after I switched back to "real news" sites, I could not believe it was not satire. I mean come on, the world and the internet was always full of dumb people, but when even very high ranking people and institution say really out of the world things in all seriousness - I came to the conclusion, marking irony as irony is sadly sometimes important, in those interesting times we live ...

Re: A Modern JavaScript Tutorial

#26

> According to your browser language headers, you know Chinese. Please help to translate the tutorial into your language! Thank you! I'm curious. How are my language preferences exposed through HTTP headers? I think this was a charming way to request volunteers for translation, but I was a bit taken aback.

Is your next thought after having your curiosity piqued not, "I should look at what headers my browser is sending", or "I should type 'browser language headers' into a search engine"? I'm trying to understand what sort of things lead people instead to think, "I should type a question about 'browser language headers' into a comment box on an off-topic thread, wait for a response, and then go back and check what the re…

Maybe he did fo that but wanted to inform the OP that this was surprising to him. Given that the OP is looking for translators it is valuable feedback imo.

Re: A Modern JavaScript Tutorial

#27
post #5

The default way promises are used is now async/await. `.then()` should not be introduced as anything more than 'you may find this in older codebases'.

Maybe some codebases mandate it, but it's very common to use either style when it makes the most sense. The classic syntax is by no means deprecated or superseded by async/await.

[deleted]

Re: A Modern JavaScript Tutorial

#28
post #14
post #12

Earlier quoted context omitted.

No, just experience with a lot of codebases. Here's a simple question to ask yourself: what if non-IO operations allowed you to use the .then() syntax? If you have the choice to use: 1 + 1.then(function(result) { ... } vs const result = 1 + 1 Which would you choose?

Using then() doesn't pause execution of the callsite function, while await does. Surely that's a relevant difference here? It doesn't seem unreasonable to use then() to express: "Run this anonymous function whenever the async thing completes. Meanwhile let's do this other stuff right now."

Both codebases can't do anything until `result` has a value.

Re: A Modern JavaScript Tutorial

#29
post #5

The default way promises are used is now async/await. `.then()` should not be introduced as anything more than 'you may find this in older codebases'.

> The default way promises are used is now async/await. `.then()` should not be introduced as anything more than 'you may find this in older codebases'. No, because you might have to write explicit promises in the browser with async API that are callback based. You need to understand how promises work to use async/await at first place anyway. Just like it's better to understand how prototypal inheritance works in JS…

"Just like it's better to understand how prototypal inheritance works in JS BEFORE even using a single class declaration. "

About that, does JS class inheritance now work like classes in java for example? Or is it still just syntactic sugar for the prototype inheritance? By your wording, I assume the later?

Re: A Modern JavaScript Tutorial

#30
Oh no! It's already out of date! (That's a JS changes too fast joke)

But seriously, calling it 'modern' is pointless. It's not adding anything valuable and its just going to become out of date (and thus wrong).

Post reply on HN