A Modern JavaScript Tutorial
241–250 of 299 posts
Re: A Modern JavaScript Tutorial
#242This is not a tutorial [1]. It's more like a guide [2]. [1]: https://documentation.divio.com/tutorials/ [2]: https://documentation.divio.com/how-to-guides/ Edit: I don't mention this to be nitpicky. I mention it because I wish that we would collectively start standardizing those terms. I think it would be helpful if, whenever we saw "… guide" or "… tutorial" we had a general idea about the structure and purpose of th…
> How-to guides take the reader through the steps required to solve a real-world problem.
That is from the linked article on how-to guide. By "real-world problem" it means something specific you might want to do to a real code base, like "switch to a different database engine" or "add user authenticaion". That's why it includes the qualification "real-world". The original article definitely does not fall into that category.
> * A tutorial is what you decide a beginner needs to know.
> * A how-to guide is an answer to a question that only a user with some experience could even formulate.
That was some extra clarification from the linked article on the difference between tutorial and how-to guide. That makes it even more clear that the article is more like a tutorial than a how-to guide.
> Tutorials are lessons that take the reader by the hand through a series of steps to complete a project of some kind.
That's from the page about tutorials. The article introduces a reader to a substantial new topic from scratch and guides them through it, but it doesn't do so by making them complete a specific project, so it doesn't fit this definition.
But that doesn't stop it from being a "tutorial". The requirement that tutorials have to involve completing a sample project is invented by the author of that page and not part of the usual definition of that word.
This final point is pure conjecture, but I suspect the author of that page was just trying to strongly encourage people to base tutorials around sample projects. It's fair to encourage that, because often tutorials are improved by basing them around a single unifying project (but not always). But putting it in their definition of the word was a mistake, because that's not what that word means, and it's only created confusion.
Re: A Modern JavaScript Tutorial
#243Earlier quoted context omitted.
I looked at those links. Here's what I got from them: 1. Tutorials "are lessons that take the reader by the hand through a series of steps." They "are oriented towards learning how." 2. How-to guides "take the reader through steps." 3. "How-to guides are wholly distinct from tutorials." If I found a "community" around a topic, do I then get to decide what words mean? By consensus, of course.
You can see a good breakdown of what they mean by each label in this table: https://documentation.divio.com/introduction/#the-secret It's certainly a valuable take, even if you disagree with the claim that all 4 functions are required for good documentation.
> oriented to: learning
> must: allow the newcomer to get started
> its form: a lesson
> analogy: teaching a small child how to cook
It does not satify all the requirements of any other column.
Re: A Modern JavaScript Tutorial
#244Remember when some people advocated not using semicolons to end statements? Good times... https://javascript.info/structure
I don't know whether I use them or not, to be honest (and I just finished a project in js). My code looks like whatever the almost-default (tab-width: 4) output of prettier is. It's nice to not waste a single braincycle on these things anymore.
Re: A Modern JavaScript Tutorial
#245Re: A Modern JavaScript Tutorial
#246The 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'.
(async () => { set(await get()); })(); get().then(r => set(r)); Ignoring error handling I'll often choose the second option.
const result = await get()
set(result)
But you do you.Current node and console have top level await BTW.
Re: A Modern JavaScript Tutorial
#247The 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…
PS I should clarify await and Promise.all/any work fine:
await Promise.all(items)Re: A Modern JavaScript Tutorial
#248Remember when some people advocated not using semicolons to end statements? Good times... https://javascript.info/structure
https://news.ycombinator.com/item?id=2024328 Here’s an example great bike shed discussion from ~10y ago about whether or not to use semicolons with JavaScript. “If you don’t understand how statements in JavaScript are terminated, then you just don’t know JavaScript very well, and shouldn’t write JavaScript programs professionally without supervision, and you definitely should not tell anyone else how to write their J…
Re: A Modern JavaScript Tutorial
#249Earlier quoted context omitted.
Can you give an example of more fine grained control with then?
const [result1, result3] = await Promise.all([task1(), task2.then(res => task3(res))])
async function getResult3(){
const res = await task2()
return task3(res))
}
const [result1, result3] = await Promise.all([task1(),
getResult3()])Re: A Modern JavaScript Tutorial
#250JavaScript has some really nice features that this tutorial does not mention 1) First class functions 2) Prototype 3) Function scope 4) What async means and how to master it Those I think is essential in order to understand JavaScript.
This website covers every nitty gritty detail of javascript, even DOM specific aspects like https://javascript.info/bubbling-and-capturing (just look at how well it is written). I would be highly surprised if it did not even mention those javascript basics. A brief look at its table of contents shows that indeed it mentions those, and I am baffled why the other commentor is getting downvoted for calling you out.
Helpful resource: http://callbackhell.com/