JavaScript in the Industry How professional teams want you to write code (Simon Høiberg)(Z-Library)
JavaScript
In this book you will learn how professionals write JavaScript - in the industry. You know, out there in the real world.
AI Reading Assistant
Whole-book reading guide from stratified index samples; jump to passages in the text
AI guide
【One-Line Pitch】
A short, opinionated field guide to how professional JavaScript teams actually want code written—declarative, clean, and review-ready. Best for developers who already know the syntax and now want the conventions that get pull requests approved.
【Book Arc】
- **Opening (~0%–15%)**: Frames JavaScript as a multi-paradigm language and argues that the functional, declarative style is the industry default; contrasts imperative vs. declarative code and introduces purity and immutability as the core test.
- **Early (~15%–35%)**: Applies the declarative mindset to everyday array work, warns about mutating methods like `sort`, `push`, and `splice`, and makes the case for avoiding classes in favor of plain functions and hooks.
- **Middle (~35%–60%)**: Moves into control flow and code hygiene—guard clauses, skipping `else`, when a `switch` is acceptable, partial application/currying, passing arguments as objects, and returning associated data as tuples.
- **Late (~60%–80%)**: Shifts to TypeScript and React practice: don't over-annotate, let inference work, avoid `any`, use hooks well, and stop overusing `useMemo` and `useCallback`.
- **Ending (~80%–100%)**: Closes with Node.js and AWS Lambda patterns—promises over callbacks, `promisify`, async handlers—plus a short "which conventions should I use?" wrap-up and additional resources.
【Key Takeaways】
- **Declarative beats imperative for team code** (Opening): Pure functions with return values and no mutation are easier to test, debug, and review—imperative loops that mutate external state are the classic PR rejection.
- **`let` is a smell; `const` is the default** (Early): If you're reassigning a variable, ask whether an array method or a different structure could express the same result without mutation.
- **Beware the mutating array methods** (Early): `sort`, `push`, `shift`, `unshift`, `pop`, `reverse`, `splice`, and `fill` alter the original array; copy first with spread (`[...arr]`) when you must use them.
- **Classes are usually unnecessary** (Early): Plain functions and closures are more testable, debuggable, and tree-shakable—modern build tools can drop unused function code, shrinking bundles.
- **Guard clauses and no `else`** (Middle): Flatten nested conditionals with early returns; an `else` often signals a function doing too much. Ternaries are fine only for direct assignment or return, never nested branching.
- **Abstractions are the escape hatch** (Middle): When strict declarative code becomes verbose, wrap the messy imperative logic in a pure function and call it declaratively—purity inside the function is what matters.
- **Object arguments scale better than positional ones** (Middle): Wrapping arguments in an object (with destructuring) makes call sites readable, order-independent, and easier to extend with optional properties.
- **TypeScript and React reward restraint** (Late): Let inference do the work, avoid `any`, don't return JSX from inner functions, and resist reflexive `useMemo`/`useCallback`—overuse adds complexity without benefit.
【Reading Tips】
- **Deep-read the functional-style and control-flow chapters** (roughly the first half): these carry the book's core argument and the examples you'll actually reuse in reviews.
- **Skim the React and TypeScript sections if you're not in that stack**, but note the recurring principle—don't over-engineer—since it applies broadly.
- **Treat the code examples as review checklists**: after each pattern, ask whether your current codebase violates it and what a minimal refactor would look like.
- **Pay attention to the "create your own abstractions" chapter**: it's the pragmatic counterweight to the strict rules and the most useful for real deadlines.
- **Keep the mutating-methods list handy** as a quick reference during code review.
【Coverage Limits】
This guide is based on stratified excerpts covering the table of contents and the functional-style, control-flow, and hygiene chapters in most detail; the TypeScript, React, and Node/Lambda sections are represented mainly by their headings and brief mentions, so specific examples there are not fully covered.
Page 5
h object-oriented languages such as Java and C# have had an enormous impact on the industry, the functional style JavaScript is the most popular and accepted...
View in text
Page 14
e another example. Sorting! 13 This one gets a bit messier. Take a look at the code below. At first glance, this looks good. We’re not using let, and we’re n...
View in text
Excerpt 3
the final result. Procedural code is still imperative code. You can reassign variables, alter data outside of loops, and mutate on arrays. But you still cann...
View in text
Excerpt 4
f-else-if… a series of times, you probably want to consider using a switch-statement instead. There are certain libraries, for instance, Redux for React, tha...
View in text
Excerpt 5
ery often: Passing optional arguments as an options object. This is adopted in NodeJS and a range of well-known Open-Source libraries. 44 The idea is to pass...
View in text
Excerpt 6
ls that auto-generate these interfaces based on the schema. This part of TypeScript that’s not annoying, but simply saves time, seems to be quite popular wit...
View in text
Excerpt 7
, improper use of useCallback actually worsens performance. If you’re in doubt when to use useCallback, remember that as a rule of thumb, you’re not going to...
View in text
Excerpt 8
.com/SimonHoiberg Twitter: https://twitter.com/SimonHoiberg LinkedIn: https://www.linkedin.com/in/simonhoiberg/ Instagram: https://www.instagram.com/simonhoi...
View in text
Tags
AI categories
JavaScriptProgrammingCode
Text Preview (First 20 pages)
Registered users can read the full content for free
Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.
Generating text preview…
Loading comments...
Reply to Comment
Edit Comment