When reading documentation or articles that contain code, do your prefer to:
- step through the file line-by-line
- see the full code snippet pasted with inlined comments
- see the full snippet, and a summary/walk-through after?
Here's an example of #2/3 taken from a recent post of mine:
import hashids from "hashids";
// Two arguments supplied: a salt and a minimum padding (length)
const postHash = new hashids("post", 8);
const post = { id: 4 };
post.id; // 4
const hashedPostId = postHash.encode(post.id);
hashedPostId; // 6akz1JVq
postHash.decode(hashedPostId); // [4]
"Here, we're importing the hashids package and creating an instance of the module, calling it postHash. ..."
vs. doing something like:
const postHash = new hashids("post", 8);
"First, we create an instance of the hashids module and supply a salt and padding. ..."
Top comments (0)