18 ms·
Show HN: The JavaScript Way, a new book for learning modern JS
- gigatexal 10y agoBookmarked. Hoping this proves to be the structured intro to web development and JS that I need.
- antfarm 10y agoMaybe "Front-End Web Development: The Big Nerd Ranch Guide" is what you are looking for. https://www.amazon.com/Front-End-Web-Development-Ranch-Guides/dp/0134433947/ https://www.amazon.com/Front-End-Web-Development-Ranch-Guide...
- pignut 10y agonice pile of shit book. try finishing it next time before you post it on HN for free advertising
- dang 10y agoWe've banned this account for violating the HN guidelines.
- ivraatiems 10y agoI appreciate the effort that went into this, and it's certainly important to have a good clear reference on JS. Unfortunately, I can't support the effort to aim this at beginners, because I think JS is an extremely poor choice of language for first-time developers. It's poorly designed, with too many side effects and edge cases and confusing behaviors to be a good choice for a first language. It will bog down first-time learners with weird minutiae, and it will do that because it is a poorly/hastily built language that is being used in ways it was never intended for. I realize JS is ubiquitous and easy to access (since all browsers have it), but that doesn't make it the right choice. It's just too broken.
- nickthemagicman 10y agoThis is great. Also wanted to toss out its asynchronous nature is not great for beginners either in my opinion.
- nevon 10y agoWhy not? What language makes dealing with asynchronous problems easier for a beginner? const getTweets = (username) => return fetch(`https://api.twitter.com/${username}`) getTweets('nevon').then(console.log).catch(console.error) Really isn't that bad, although you have to know promises. With regular callbacks, I guess you have to know that functions can be passed as arguments, but you'll have to learn that quite soon regardless. const getTweets = (username, callback) => { const req = new XMLHttpRequest() req.onload = function () { return request.status === 200 ? callback(undefined, JSON.parse(this.responseBody)) : callback(Error(request.statusText)) } req.onerror = callback req.open('get', `https://api.twitter.com/${username}`, true) req.send() } getTweets('nevon', (err, tweets) => { if (err) { console.error(err) } else { console.log(tweets) } }) Most of the confusing crap in there is because of XMLHttpRequest, not asynchronicity. With async functions, which I personally am not a huge fan of, you can get synchronous looking code if you believe that's more beginner friendly: async function getTweets (username) => { const response = await fetch(url) return response.json() } getTweets('nevon').then(console.log).catch(console.error)
- ivraatiems 10y agoI don't think "is this behavior synchronous or asynchronous" is where we should start when teaching new developers, period.
- nickthemagicman 10y agoLol, asynchronous is harder to reason about than synchronous. Plus just about anything goes in the browser. You can put anything anywhere and alot of things are global by default! And as a noob you have enough on your plate learning OOP and REST. I'm glad I started with Ruby and Java and got really good at OOP and clean compartmentalized code before jumping into the madness that is browser land. Just my opinion.
- rco8786 10y ago> using latest language standard(ES6/ES2015), avoiding awkwardnesses from the past > `Object.create` :(
- bpesquet 10y agoCare to elaborate? Understanding prototypal inheritance seems essential to me, and Object.create() is the cleanest way to show it in action. The book also presents the alternative class syntax and numerous ES2015 additions like block-scoped variables and arrow functions, to name a few.
- rco8786 10y agoIt explicitly states it avoids the past and focuses on es2015, but then talks about old patterns.
- bpesquet 10y agoI don't consider Object.create() and factory functions to be "old patterns", but YMMV. How would you teach OOP basics to a JS newcomer then? Using only class without mentioning prototypes?