NVM Install and Use Latest LTS
With my Node versions managed via NVM, I want to be on the latest LTS. You can ensure that happens with these commands: $ nvm install --lts $ nvm alias default lts/* default -> node (-> v24.16.0) ...
With my Node versions managed via NVM, I want to be on the latest LTS. You can ensure that happens with these commands: $ nvm install --lts $ nvm alias default lts/* default -> node (-> v24.16.0) ...
What I call “wraparound” are repeatable indices on an array. The common use case is a carousel. Here’s how it’s done: const items = ["first", "middle", "last"]; const i = 0; // Our iterable index // "Next" -> const nextIndex = (i + 1) % items.length; // <- "Previous" const prevIndex = (i - 1 + items.length) % items.length;
Here’s a periodic reminder that JavaScript supports string concatenation with a plus sign: > 'foo' + 'bar' 'foobar' ...
Need an array of letters? Here’s a trick: > const alpha = [...'abcdefghijklmnopqrstuvwxyz'] ...
When you join an array in JavaScript, the default separator is a comma: node> ['j', 'a', 'k', 'e'].join() 'j,a,k,e' ...
The JavaScript bitwise AND operator (&) can be used for some real-world tasks, like testing if a number is odd or even. ...
Most JavaScript projects come with a package.json. But what if you want to make a new one? ...
How can I output the entire DOM to a file in a JavaScript test? ...
I’ve been hacking on a TypeScript file all day, but I need transpiled JavaScript for any testing. How did I reduce cycle time (and mitigate many chances to forget to build at all)? ...
Suppose your package.json specifies a Node engine of greater than or equal 24. Does this mean all engineers on your team will use Node 24? No, unless you use this one weird trick! ...