Live data from Hacker News

Show HN: The JavaScript Way, a book for learning modern JavaScript from scratch

github.com

41–50 of 113 posts

Re: Show HN: The JavaScript Way, a book for learning modern JavaScript from scratch

#41
post #2

Hi all, author here. Backstory: I'm a CS engineer/teacher and this book is a side project started in December 2016. You can read a bit more about it here: https://medium.com/@bpesquet/walk-this-javascript-way-e9c45a... . The writing process is now completed and I'm actively looking for feedback to make the book better. Any opinion or advice about content, pricing, or that hastily created Leanpub cover would be greatl…

It might be too much to ask, but I really liked how the KnockoutJS tutorial was presented http://learn.knockoutjs.com/

You basically live code to learn the basics right in a browser. It would be cool to have something like this for the book

Re: Show HN: The JavaScript Way, a book for learning modern JavaScript from scratch

#42
post #38

Earlier quoted context omitted.

Works in Firefox, not in Chrome (at least on MacOS).

Doesn't work in Chrome (edit: or Firefox for that matter) for Windows either... that's a shame. Abusing javascript: is a really useful trick for lots of little hacks.

It's also an attack vector for hacks. You can enable it on some browsers if you please, but having it off by default is sensible...

Re: Show HN: The JavaScript Way, a book for learning modern JavaScript from scratch

#45

Didn't know "var" was outdated. Good stuff, thanks!

You can technically still use var if you wish, but I'm not sure of any reasons to do so.

When switching to let/const, bear in mind the difference in scope:

var is function-scoped:

    (function () {
      var x = 1;
    })();

    var x === undefined
let/const are block-scoped:

    if (true) {
      var x = 1;
      let y = 1;
      const z = 1;
    }
    x === 1
    y === undefined
    z === undefined

Re: Show HN: The JavaScript Way, a book for learning modern JavaScript from scratch

#46
post #38

Earlier quoted context omitted.

You could start with, "type 'javascript:alert(2+2);'" in your address bar

Works in Firefox, not in Chrome (at least on MacOS).

Works if you type it out. If you paste it, the "javascript:" part will be omitted.

Re: Show HN: The JavaScript Way, a book for learning modern JavaScript from scratch

#47

Earlier quoted context omitted.

Except on almost any serious project you should be using a transpiler anyways.

Agreed, but I find it helpful to understand the transpiled code. The "clean" ES5 output was a large reason for using TypeScript https://blog.asana.com/2014/11/asana-switching-typescript/

I agree to an extent, but any modern transpired should also emit source maps which should shield most people from needing to look st or understand the "low level" generated code.

Re: Show HN: The JavaScript Way, a book for learning modern JavaScript from scratch

#48
post #9

I just got home from teaching JavaScript to a room full of people who've never written a line of code in their life. This book is missing something critical that most intros to JavaScript overlook: How does the student set up the plumbing and run their code? It's amazing how much of a hump this is for many trying to get started. It also amazes me how oblivious most of us programmers are to it. "Just open Chrome Dev T…

Very true. Or things like "download and install git". Oh wait you're on a mac you need Brew. But you're on windows? You're gonna need X. You're using linux and still don't know? (e.g. Parent installs linux on a computer for their child to learn programming on (e.g. buys them a rpi) ) Lots of "setup" stuff needs to be explained or at least guided through for a from scratch approach, but also needs to be easy to skim a…

Sometimes I fantasize about a platform for tutorials on "how to do X using Y if you know Z" where prerequisites would be linked wiki-style, but disambiguated for the learner. If they are on Windows and use cmd.exe as their shell, command-line examples would be adapted to that, while someone using bash on Linux would get fitting examples as well. If they already know how to do a part, they get just a short summary instead of lengthy explanations.

Unfortunately, you'd need a lot of content before something like that would take off, and just specifying a few options while otherwise relying on the reader to figure out any differences is simply easier for a writer and still good enough for most learners.

Re: Show HN: The JavaScript Way, a book for learning modern JavaScript from scratch

#49
post #38

Earlier quoted context omitted.

You could start with, "type 'javascript:alert(2+2);'" in your address bar

Works in Firefox, not in Chrome (at least on MacOS).

What about

  data:text/html,alert(2+2)

?

Re: Show HN: The JavaScript Way, a book for learning modern JavaScript from scratch

#50
post #45

Didn't know "var" was outdated. Good stuff, thanks!

You can technically still use var if you wish, but I'm not sure of any reasons to do so. When switching to let/const, bear in mind the difference in scope: var is function-scoped: (function () { var x = 1; })(); var x === undefined let/const are block-scoped: if (true) { var x = 1; let y = 1; const z = 1; } x === 1 y === undefined z === undefined

The only reason I can think of is if you want hoisting for some reason. For example, if you want to call functions before they are declared. Personally, I don't like that style, but some people do.
Post reply on HN