Appendix D. Reintroducing JavaScript

This appendix covers

  • Applying best practices when writing JavaScript
  • Using JSON effectively to pass data
  • Examining how to use callbacks and escaping callback hell
  • Writing modular JavaScript with closures, patterns, and JavaScript classes
  • Adopting functional programming principles

JavaScript is such a fundamental part of the MEAN stack (even if you’re writing the Angular part with TypeScript) that we’ll spend a little bit of time looking at it. We need to cover the bases because successful MEAN development depends on it. JavaScript is such a common language (uniquely, JavaScript has a runtime on almost every computer currently on the planet) that it seems that everybody knows some of it, partly because JavaScript is easy to start with and forgiving in the way it’s written. Unfortunately, this looseness and low barrier to entry can encourage bad habits, which can cause unexpected results.

The aim of this appendix isn’t to teach JavaScript from scratch; you should already know the basics. If you don’t know JavaScript at all, you may struggle and find it hard going. Like all things, JavaScript has a learning curve. On the other hand, not everybody needs to read this appendix in detail, particularly experienced JavaScript developers. If you’re lucky enough to count yourself as part of the experienced camp, it still may be worthwhile to skim this appendix in case you find something new here.

Everybody knows JavaScript, right?

Good habits or bad habits

Arrow functions

Destructuring

Logic flow and looping

Getting to know JSON

Formatting practices

String formatting

Understanding callbacks

Promises and async/await

Writing modular JavaScript

Classes

Functional programming concepts

Final thoughts

sitemap