Live data from Hacker News

A Modern JavaScript Tutorial

javascript.info

31–40 of 299 posts

Re: A Modern JavaScript Tutorial

#31
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'.

That’s probably good general advice. One problem. I’m increasingly coming across devs who’ve never used Promises directly, only async/await. They’re introducing all kinds of problems into code because they don’t have that foundational understanding of Promises. I think it’s essential to know how Promises work, even if we generally recommend async/await. Also, Promise interface can do things that async/await cannot, s…

100%, people should definitely understand Promise.all() and Promise.any().

Re: A Modern JavaScript Tutorial

#32

> 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: since I'm already here I'll ask the question because on this particular site somebody knows the answer and can probably give me a better starting point for learning about the subject than the average search engine!

Also it will serve as a notice to people that not everybody knows these things and might be put out by this sort of question.

Re: A Modern JavaScript Tutorial

#33

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.

It's only encouraged within certain contexts. Like it says, short lived stuff can be named "x" or "i". We already do this in almost every language. "c" for "count" or "i" for "index" isn't specific to Go, I've seen and done that in every language I've used.

Stuff that isn't easily understood should be named appropriately but shortness is encouraged.

If you're storing an index in a global variable or a struct field then it should be called "index" not "i".

Method receivers are usually always kept short because they're pretty self explanatory and the first thing you look at in a function.

Re: A Modern JavaScript Tutorial

#34

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.

I kind of agree with their reasoning, the exception being when you can have a lot of complicated looping/control flow breaks or transient variables close to their usage. Seeing 'array[i][j][k]' is never fun.

Re: A Modern JavaScript Tutorial

#35

> 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.

I get the same question (after a while) here: https://www.wpf-tutorial.com/

Re: A Modern JavaScript Tutorial

#36

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).

Honestly, it’s fine if documentation goes out of date, otherwise what’s the point of writing anything at all? The onus is on the reader to check the publish date of what they are reading, and to cross reference it with other sources to ensure accuracy.

Re: A Modern JavaScript Tutorial

#37

> 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…

I think this is a little harsh. The comment does point out a feature on the topic site. I'm personally glad that they brought it up because as an English speaker I didn't see this feature exposed. Internationalisation is a complex yet required feature for large websites these days, and a clever feature like this to find translations is great!

Re: A Modern JavaScript Tutorial

#38

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).

I think it’s precisely the fact that js is constantly changing that they’ve branded this as “modern”.

Re: A Modern JavaScript Tutorial

#39

> 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.

I have figured it out experimentally (Chrome & Ukrainian): if you visit a website in language X and click Never Translate, Chrome silently adds language X to the end of the list (Accept-Language that is). I have not found a way to forcibly turn it off.

Edit: check out chrome://translate-internals/ if you are interested

Re: A Modern JavaScript Tutorial

#40

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).

Disagree. I've been writing JavaScript for twenty years, and I'm very aware that there's a lot of "new" stuff that I need to brush up on. When I saw it call itself "modern" I instantly assumed that it would be covering the kind of information I need to know.
Post reply on HN