Live data from Hacker News

A Modern JavaScript Tutorial

javascript.info

261–270 of 299 posts

Re: A Modern JavaScript Tutorial

#261

This site is absolutely awesome and I would suggest this to new comers and experienced folks alike. It covers all things related to javascript, explains the concepts really well in a practical day to day application point of view. I might be sounding like a promoter for it, but it really added a lot of value for me personally, so just wanted to spread the good word.

I just wish it didn't have Disqus :(

The addon Privacy Badger blocks it by default.

Re: A Modern JavaScript Tutorial

#262
The website is really very good. I started to learn JavaScript last week and worked through the JavaScript Wikibook. Unfortunately it is not as complex as the website linked above. I can continue working with it really well. I also like the structure and design, which makes the tutorials really easy to read. A great project.

Re: A Modern JavaScript Tutorial

#263
Looks well written, but it seems undecided on whether it's targeting experienced programmers or newcomers. I have to disagree with priyatham_'s position that it effectively targets both.

The Loops section gives a very brief description of what loops are. This doesn't introduce anything of value to an experienced programmer, and it's nowhere near enough of an explanation for teaching imperative programming to a beginner.

Personally I'd suggest targeting experienced programmers. I only learnt JavaScript relatively recently, and I found it very frustrating that every JavaScript tutorial I could find was aimed at beginners (and that isn't an exaggeration).

Re: A Modern JavaScript Tutorial

#264
post #222

Earlier quoted context omitted.

>I have yet to encounter a single "gotcha" out of omitting semicolons. keyword "yet". It seems like such a insignificant win, with the downside being some very hard to debug runtime error because one element of your build chain has a bug or misses an edge case. I honestly don't see the logic.

It just makes the code slightly easier to read. The semicolon is just noise.

I disagree that the semicolon is noise Thought the Javascript interpretter (usually) does not need it the semicolon is good for humans who read the code after you Sure it is possible to read the code without the semicolons with some practice but the semicolons are standard in many other related languages among them Java C++ PHP and MySQL Now you personally might not use those other languages very often but many of us especially those who occasionally wear a devops hat do And if the code is not meant to be read by humans also then why are we not writing in assembly

Re: A Modern JavaScript Tutorial

#265

Earlier quoted context omitted.

It just makes the code slightly easier to read. The semicolon is just noise.

Semicolons aren't noise; you've read the statement before you even get to them so how can they be noise? Noise would be type info added to languages that didn't have it before, such as TypeScript. Generics can get pretty gnarley too, when you have nested typing info involved.

Noise as in new line already terminates. That’s one reason Python and Ruby code are cleaner to read.

Re: A Modern JavaScript Tutorial

#266
This is great. However, it gives the example of copying a variable by assigning another variable to it. This doesn't copy a variable's contents - it makes the new variable a pointer to the original variable.

As someone who doesn't use Javascript much... is there a way to force it to copy the current state of the original variable to the new variable, without it being a reference and without having to use something like lodash?

Re: A Modern JavaScript Tutorial

#267

This is great. However, it gives the example of copying a variable by assigning another variable to it. This doesn't copy a variable's contents - it makes the new variable a pointer to the original variable. As someone who doesn't use Javascript much... is there a way to force it to copy the current state of the original variable to the new variable, without it being a reference and without having to use something li…

You will need to clone the object somehow. The simplest solution is to go through each of the object properties and create a new object with those same properties (_.clone). Alternatively, recursively go through each property in the object and then keep going deeper through each property that is an object until you get a copy of everything to assign to a new object (_.deepClone)

Re: A Modern JavaScript Tutorial

#268

This site is absolutely awesome and I would suggest this to new comers and experienced folks alike. It covers all things related to javascript, explains the concepts really well in a practical day to day application point of view. I might be sounding like a promoter for it, but it really added a lot of value for me personally, so just wanted to spread the good word.

I just wish it didn't have Disqus :(

What's wrong with Disqus? Seems relatively benign among things that people might be tempted to force upon the people who use their site.

Re: A Modern JavaScript Tutorial

#269

This is great. However, it gives the example of copying a variable by assigning another variable to it. This doesn't copy a variable's contents - it makes the new variable a pointer to the original variable. As someone who doesn't use Javascript much... is there a way to force it to copy the current state of the original variable to the new variable, without it being a reference and without having to use something li…

I think the only reasonable thing that js can do here is what it does - copy the reference. Also, there is a simple way to copy all properties from a object: const copy = { ...object }; Of course, if these properties are themselves objects, then changes in one of them will appear in the other.

One way to have a deep copy which shares nothing is const copy = JSON.parse(JSON.stringify(object)); but that may not always work. In short, copying a arbitrarily large object will probably waste memory, so it should be a little hard so you don't do it unless it's really necessary.

Re: A Modern JavaScript Tutorial

#270

This is great. However, it gives the example of copying a variable by assigning another variable to it. This doesn't copy a variable's contents - it makes the new variable a pointer to the original variable. As someone who doesn't use Javascript much... is there a way to force it to copy the current state of the original variable to the new variable, without it being a reference and without having to use something li…

The cheaty way is `let copy = JSON.parse(JSON.stringify(val))`. Doesn't work for functions or cyclic structures though.
Post reply on HN