There are many popular web app frameworks out there. But if you’re building a website, like a blog, a portfolio or a company site, where do you start these days?
Most people will go with one of these big frameworks. One they are comfortable with. But at what cost? It might cost you slower load times with all these kB added to your pages for features you won’t use. And it might add complexity where you don’t need, with these pages and pages of documentation you’ll have to learn, especially if you are starting out.
So vanilla HTML, CSS and…
There are countless ways to iterate through JS objects and arrays. Here’s how to do it in the simplest way, with ES6 and beyond, for each purpose.
Loop through keys and values of an object.
Loop through keys of an object.
Loop through values of an object.
Loop through an array.
If you want to return
the items or the whole loop, you have to swap the forEach
for a map
. You can change it in any of the examples above, it will work as expected, and the result will be returned. A forEach
will always return undefined
.
Build a simple Node.js CLI tool without any dependencies. A single command to clone
and install
a repository.
Npm has a great command called init
. Running the command npm init <something>
temporarily installs a package you named create-<something>
to run its main
entry. It uses npx
under the hood, but with a more familiar command.
One significant advantage of init
is that it always uses the latest version of your package; you don’t have to update it manually as you would have to globally. But it still works, you can install the package globally if you prefer.