We’re hiring. Write for Howchoo
We’re hiring. Write for Howchoo
We’re hiring. Write for Howchoo
We’re hiring. Write for Howchoo
We’re hiring. Write for Howchoo
We’re hiring. Write for Howchoo
Want to support Howchoo? When you buy a tool or material through one of our Amazon links, we earn a small commission as an Amazon Associate.
Want to support Howchoo? When you buy a tool or material through one of our Amazon links, we earn a small commission as an Amazon Associate.
Newer JavaScript developers are bound to be confused by the many ways to do a simple loop. Everyone seems to use for (var i=0; i < array.length; i++), but is there a simpler syntax? How do I handle objects? And what is forEach?
This guide will teach you how to use each option while taking you through my journey to find the one for loop operator to use 100% of the time so I never have to think about it again.
Posted in these interests:
You know it, you love it, the loop classic:
let fruits = ["apple", "banana", "jackfruit"]; for (let i = 0; i < fruits.length; i++) { console.log(fruits[i].slice()); } It works but isn’t there something nicer to use out there?
for...in is not what you are looking for. You might think you can do this:
// BAD CODE let fruits = ["apple", "banana", "jackfruit"]; for (let fruit in fruits) { console.log(fruit.slice()); } But this prints the following:
0 1 2 It prints the index of each item because the for...in loop iterates through an object’s enumerable properties. For an object, that iterates through the object’s keys. For an Array, that is actually the index.
We can fix the code by doing the following:
let fruits = ["apple", "banana", "jackfruit"]; for (let fruit in fruits) { console.log(fruits[fruit].slice()); } But now we have a super confusing line there: fruits[fruit]
Add to that, Mozilla explicitly warns users not to use for...in if the order of the elements matters.
Why, JavaScript?
for...of is actually closer to what you’d expect from a simple loop operator. It works like this:
let fruits = ["apple", "banana", "jackfruit"]; for (let fruit of fruits) { console.log(fruit.slice()); } This outputs what you would expect (hope at this point).
One major snag though, you do not have access to the key, which in this case is the index that for...in was printing. It’s pretty common to need the index so this cannot be the solution I always reach for.
forEach is a method that can be called on Arrays. It looks like this in the wild:
var fruits = ["apple", "banana", "jackfruit"]; fruits.forEach(function(fruit) { console.log(fruit.slice()); }); Slice pun aside, this is pretty simple right? It isn’t the most elegant syntax necessarily but it reads very well and it seems like it’s going to do what it says it’s going to do. Does this means it can be the tool you always reach for? For many yes, but there is one gotcha that breaks the deal for me. You cannot a break or continue operator within the loop and the return statement does nothing whatsoever.
I was so close to just accepting forEach but that snag was big enough that I could never feel truly secure reaching for it 100% of the time.
That’s right. The OG for (var i=0; i < array.length; i++) syntax won in the end. Between the rapport I already had with this operator and the fact that every JavaScript developer I know is very familiar with it, I decided to stop seeking greener pastures and stick with what I knew.
Honestly though, if it’s reasonable to include a third party library, lodash’s loops will solve all of your problems. They look just like forEach but you can use break, continue, and they are significantly faster.
let fruits = ["apple", "banana", "jackfruit"]; _.forEach(fruits, function(element, i) { console.log(element); });Newer JavaScript developers are bound to be confused by the many ways to do a simple loop. Everyone seems to use for (var i=0; i < array.length; i++), but is there a simpler syntax? How do I handle objects? And what is forEach?
This guide will teach you how to use each option while taking you through my journey to find the one for loop operator to use 100% of the time so I never have to think about it again.
Posted in these interests:
You know it, you love it, the loop classic:
let fruits = ["apple", "banana", "jackfruit"]; for (let i = 0; i < fruits.length; i++) { console.log(fruits[i].slice()); } It works but isn’t there something nicer to use out there?
for...in is not what you are looking for. You might think you can do this:
// BAD CODE let fruits = ["apple", "banana", "jackfruit"]; for (let fruit in fruits) { console.log(fruit.slice()); } But this prints the following:
0 1 2 It prints the index of each item because the for...in loop iterates through an object’s enumerable properties. For an object, that iterates through the object’s keys. For an Array, that is actually the index.
We can fix the code by doing the following:
let fruits = ["apple", "banana", "jackfruit"]; for (let fruit in fruits) { console.log(fruits[fruit].slice()); } But now we have a super confusing line there: fruits[fruit]
Add to that, Mozilla explicitly warns users not to use for...in if the order of the elements matters.
Why, JavaScript?
for...of is actually closer to what you’d expect from a simple loop operator. It works like this:
let fruits = ["apple", "banana", "jackfruit"]; for (let fruit of fruits) { console.log(fruit.slice()); } This outputs what you would expect (hope at this point).
One major snag though, you do not have access to the key, which in this case is the index that for...in was printing. It’s pretty common to need the index so this cannot be the solution I always reach for.
forEach is a method that can be called on Arrays. It looks like this in the wild:
var fruits = ["apple", "banana", "jackfruit"]; fruits.forEach(function(fruit) { console.log(fruit.slice()); }); Slice pun aside, this is pretty simple right? It isn’t the most elegant syntax necessarily but it reads very well and it seems like it’s going to do what it says it’s going to do. Does this means it can be the tool you always reach for? For many yes, but there is one gotcha that breaks the deal for me. You cannot a break or continue operator within the loop and the return statement does nothing whatsoever.
I was so close to just accepting forEach but that snag was big enough that I could never feel truly secure reaching for it 100% of the time.
That’s right. The OG for (var i=0; i < array.length; i++) syntax won in the end. Between the rapport I already had with this operator and the fact that every JavaScript developer I know is very familiar with it, I decided to stop seeking greener pastures and stick with what I knew.
Honestly though, if it’s reasonable to include a third party library, lodash’s loops will solve all of your problems. They look just like forEach but you can use break, continue, and they are significantly faster.
let fruits = ["apple", "banana", "jackfruit"]; _.forEach(fruits, function(element, i) { console.log(element); });Newer JavaScript developers are bound to be confused by the many ways to do a simple loop. Everyone seems to use for (var i=0; i < array.length; i++), but is there a simpler syntax? How do I handle objects? And what is forEach?
This guide will teach you how to use each option while taking you through my journey to find the one for loop operator to use 100% of the time so I never have to think about it again.
Posted in these interests:
You know it, you love it, the loop classic:
let fruits = ["apple", "banana", "jackfruit"]; for (let i = 0; i < fruits.length; i++) { console.log(fruits[i].slice()); } It works but isn’t there something nicer to use out there?
for...in is not what you are looking for. You might think you can do this:
// BAD CODE let fruits = ["apple", "banana", "jackfruit"]; for (let fruit in fruits) { console.log(fruit.slice()); } But this prints the following:
0 1 2 It prints the index of each item because the for...in loop iterates through an object’s enumerable properties. For an object, that iterates through the object’s keys. For an Array, that is actually the index.
We can fix the code by doing the following:
let fruits = ["apple", "banana", "jackfruit"]; for (let fruit in fruits) { console.log(fruits[fruit].slice()); } But now we have a super confusing line there: fruits[fruit]
Add to that, Mozilla explicitly warns users not to use for...in if the order of the elements matters.
Why, JavaScript?
for...of is actually closer to what you’d expect from a simple loop operator. It works like this:
let fruits = ["apple", "banana", "jackfruit"]; for (let fruit of fruits) { console.log(fruit.slice()); } This outputs what you would expect (hope at this point).
One major snag though, you do not have access to the key, which in this case is the index that for...in was printing. It’s pretty common to need the index so this cannot be the solution I always reach for.
forEach is a method that can be called on Arrays. It looks like this in the wild:
var fruits = ["apple", "banana", "jackfruit"]; fruits.forEach(function(fruit) { console.log(fruit.slice()); }); Slice pun aside, this is pretty simple right? It isn’t the most elegant syntax necessarily but it reads very well and it seems like it’s going to do what it says it’s going to do. Does this means it can be the tool you always reach for? For many yes, but there is one gotcha that breaks the deal for me. You cannot a break or continue operator within the loop and the return statement does nothing whatsoever.
I was so close to just accepting forEach but that snag was big enough that I could never feel truly secure reaching for it 100% of the time.
That’s right. The OG for (var i=0; i < array.length; i++) syntax won in the end. Between the rapport I already had with this operator and the fact that every JavaScript developer I know is very familiar with it, I decided to stop seeking greener pastures and stick with what I knew.
Honestly though, if it’s reasonable to include a third party library, lodash’s loops will solve all of your problems. They look just like forEach but you can use break, continue, and they are significantly faster.
let fruits = ["apple", "banana", "jackfruit"]; _.forEach(fruits, function(element, i) { console.log(element); });Newer JavaScript developers are bound to be confused by the many ways to do a simple loop. Everyone seems to use for (var i=0; i < array.length; i++), but is there a simpler syntax? How do I handle objects? And what is forEach?
This guide will teach you how to use each option while taking you through my journey to find the one for loop operator to use 100% of the time so I never have to think about it again.
Posted in these interests:
Posted in these interests:
You know it, you love it, the loop classic:
let fruits = ["apple", "banana", "jackfruit"]; for (let i = 0; i < fruits.length; i++) { console.log(fruits[i].slice()); } It works but isn’t there something nicer to use out there?
for...in is not what you are looking for. You might think you can do this:
// BAD CODE let fruits = ["apple", "banana", "jackfruit"]; for (let fruit in fruits) { console.log(fruit.slice()); } But this prints the following:
0 1 2 It prints the index of each item because the for...in loop iterates through an object’s enumerable properties. For an object, that iterates through the object’s keys. For an Array, that is actually the index.
We can fix the code by doing the following:
let fruits = ["apple", "banana", "jackfruit"]; for (let fruit in fruits) { console.log(fruits[fruit].slice()); } But now we have a super confusing line there: fruits[fruit]
Add to that, Mozilla explicitly warns users not to use for...in if the order of the elements matters.
Why, JavaScript?
for...of is actually closer to what you’d expect from a simple loop operator. It works like this:
let fruits = ["apple", "banana", "jackfruit"]; for (let fruit of fruits) { console.log(fruit.slice()); } This outputs what you would expect (hope at this point).
One major snag though, you do not have access to the key, which in this case is the index that for...in was printing. It’s pretty common to need the index so this cannot be the solution I always reach for.
forEach is a method that can be called on Arrays. It looks like this in the wild:
var fruits = ["apple", "banana", "jackfruit"]; fruits.forEach(function(fruit) { console.log(fruit.slice()); }); Slice pun aside, this is pretty simple right? It isn’t the most elegant syntax necessarily but it reads very well and it seems like it’s going to do what it says it’s going to do. Does this means it can be the tool you always reach for? For many yes, but there is one gotcha that breaks the deal for me. You cannot a break or continue operator within the loop and the return statement does nothing whatsoever.
I was so close to just accepting forEach but that snag was big enough that I could never feel truly secure reaching for it 100% of the time.
That’s right. The OG for (var i=0; i < array.length; i++) syntax won in the end. Between the rapport I already had with this operator and the fact that every JavaScript developer I know is very familiar with it, I decided to stop seeking greener pastures and stick with what I knew.
Honestly though, if it’s reasonable to include a third party library, lodash’s loops will solve all of your problems. They look just like forEach but you can use break, continue, and they are significantly faster.
let fruits = ["apple", "banana", "jackfruit"]; _.forEach(fruits, function(element, i) { console.log(element); });You know it, you love it, the loop classic:
let fruits = ["apple", "banana", "jackfruit"]; for (let i = 0; i < fruits.length; i++) { console.log(fruits[i].slice()); } It works but isn’t there something nicer to use out there?
You know it, you love it, the loop classic:
let fruits = ["apple", "banana", "jackfruit"]; for (let i = 0; i < fruits.length; i++) { console.log(fruits[i].slice()); } It works but isn’t there something nicer to use out there?
for...in is not what you are looking for. You might think you can do this:
// BAD CODE let fruits = ["apple", "banana", "jackfruit"]; for (let fruit in fruits) { console.log(fruit.slice()); } But this prints the following:
0 1 2 It prints the index of each item because the for...in loop iterates through an object’s enumerable properties. For an object, that iterates through the object’s keys. For an Array, that is actually the index.
We can fix the code by doing the following:
let fruits = ["apple", "banana", "jackfruit"]; for (let fruit in fruits) { console.log(fruits[fruit].slice()); } But now we have a super confusing line there: fruits[fruit]
Add to that, Mozilla explicitly warns users not to use for...in if the order of the elements matters.
Why, JavaScript?
for...in is not what you are looking for. You might think you can do this:
// BAD CODE let fruits = ["apple", "banana", "jackfruit"]; for (let fruit in fruits) { console.log(fruit.slice()); } But this prints the following:
0 1 2 It prints the index of each item because the for...in loop iterates through an object’s enumerable properties. For an object, that iterates through the object’s keys. For an Array, that is actually the index.
We can fix the code by doing the following:
let fruits = ["apple", "banana", "jackfruit"]; for (let fruit in fruits) { console.log(fruits[fruit].slice()); } But now we have a super confusing line there: fruits[fruit]
Add to that, Mozilla explicitly warns users not to use for...in if the order of the elements matters.
Why, JavaScript?
for...of is actually closer to what you’d expect from a simple loop operator. It works like this:
let fruits = ["apple", "banana", "jackfruit"]; for (let fruit of fruits) { console.log(fruit.slice()); } This outputs what you would expect (hope at this point).
One major snag though, you do not have access to the key, which in this case is the index that for...in was printing. It’s pretty common to need the index so this cannot be the solution I always reach for.
for...of is actually closer to what you’d expect from a simple loop operator. It works like this:
let fruits = ["apple", "banana", "jackfruit"]; for (let fruit of fruits) { console.log(fruit.slice()); } This outputs what you would expect (hope at this point).
One major snag though, you do not have access to the key, which in this case is the index that for...in was printing. It’s pretty common to need the index so this cannot be the solution I always reach for.
forEach is a method that can be called on Arrays. It looks like this in the wild:
var fruits = ["apple", "banana", "jackfruit"]; fruits.forEach(function(fruit) { console.log(fruit.slice()); }); Slice pun aside, this is pretty simple right? It isn’t the most elegant syntax necessarily but it reads very well and it seems like it’s going to do what it says it’s going to do. Does this means it can be the tool you always reach for? For many yes, but there is one gotcha that breaks the deal for me. You cannot a break or continue operator within the loop and the return statement does nothing whatsoever.
I was so close to just accepting forEach but that snag was big enough that I could never feel truly secure reaching for it 100% of the time.
forEach is a method that can be called on Arrays. It looks like this in the wild:
var fruits = ["apple", "banana", "jackfruit"]; fruits.forEach(function(fruit) { console.log(fruit.slice()); }); Slice pun aside, this is pretty simple right? It isn’t the most elegant syntax necessarily but it reads very well and it seems like it’s going to do what it says it’s going to do. Does this means it can be the tool you always reach for? For many yes, but there is one gotcha that breaks the deal for me. You cannot a break or continue operator within the loop and the return statement does nothing whatsoever.
I was so close to just accepting forEach but that snag was big enough that I could never feel truly secure reaching for it 100% of the time.
That’s right. The OG for (var i=0; i < array.length; i++) syntax won in the end. Between the rapport I already had with this operator and the fact that every JavaScript developer I know is very familiar with it, I decided to stop seeking greener pastures and stick with what I knew.
That’s right. The OG for (var i=0; i < array.length; i++) syntax won in the end. Between the rapport I already had with this operator and the fact that every JavaScript developer I know is very familiar with it, I decided to stop seeking greener pastures and stick with what I knew.
Honestly though, if it’s reasonable to include a third party library, lodash’s loops will solve all of your problems. They look just like forEach but you can use break, continue, and they are significantly faster.
let fruits = ["apple", "banana", "jackfruit"]; _.forEach(fruits, function(element, i) { console.log(element); });Honestly though, if it’s reasonable to include a third party library, lodash’s loops will solve all of your problems. They look just like forEach but you can use break, continue, and they are significantly faster.
let fruits = ["apple", "banana", "jackfruit"]; _.forEach(fruits, function(element, i) { console.log(element); });Want to support Howchoo? When you buy a tool or material through one of our Amazon links, we earn a small commission as an Amazon Associate.
Want to support Howchoo? When you buy a tool or material through one of our Amazon links, we earn a small commission as an Amazon Associate.
Want to support Howchoo? When you buy a tool or material through one of our Amazon links, we earn a small commission as an Amazon Associate.


Aside from upgrading your Ender 3 board, upgrading your stock PSU to a Mean Well PSU is one of the best upgrades to make your 3D printer quieter.
In this guide, I’ll show you how to upgrade your Ender 3 to the MeanWell LRS-3500-25 PSU. This is the same power supply used on the Ender 3 Pro.
There are several reasons to upgrade your Ender 3’s PSU to a Mean Well:
Here’s everything you’ll need to complete this guide:
| MeanWell LRS-350-24 PSU | × | 1 | ||
| Screwdriver, flathead | × | 1 | ||
| Screwdriver, Phillips | × | 1 | ||
| Hex key, M3 | × | 1 |


Use a flathead screwdriver to slide the input voltage switch to either 115V or 230V, depending on your country. I’m in the US so I switched it to 115V.
You probably know which mains voltage your country uses, but if for some reason you don’t, you can reference this “Mains electricity by country” Wikipedia article.


Your MeanWell PSU probably didn’t come with a PSU cover, the bottom portion that holds the AC plug inlet and protects your terminal block from dangerous shorts (and fingers).
Since the MeanWell PSU is smaller than the stock one, the old cover won’t fit; therefore, you’ll need to print a new one. You can find tons of designs on Thingiverse, but I recommend this excellent model from TH3D Studio.
Download and print that model. I was able to print mine standing up without supports. My Ender 3 was more than capable of “bridging the gap” without stringing.


Unplug your printer’s power cable and disconnect the XT60 connector that connects the PSU to your printer.
Then, use an M3 hex key to remove the two front cap screws that secure the stock PSU to your printer’s right Z-axis vertical support.
Finally, set the old PSU aside.


We’ll need to disassemble the old PSU and transfer the AC inlet (plug) and wiring to the new MeanWell PSU.
Remove the two M3 screws from the bottom cover. Then, use a Phillips screwdriver to remove the two inlet screws.
Take a photo of the wiring (or reference my photo in the step below). Then, unscrew each screw to remove the 5 wires from the PSU terminal block.
Finally, insert the AC plug inlet into the new PSU bottom cover and secure it using the two Phillips screws.


Wire up the PSU the same as the old one. In addition to the photo I took, here’s a handy table I made to help you with your wiring:
| From | Color | To |
|---|---|---|
| XT60 cable | Red | +V |
| XT60 cable | Black | -V |
| AC inlet | Yellow | GND |
| AC inlet | Black | N |
| AC inlet | Red | L |


Route the XT60 cable through the back opening of the MeanWell PSU cover. Slide the cover into place, and secure it using the two M3 screws you removed from the old cover.


Mount your brand-new PSU to your Ender 3’s Z-axis support using the same screws that secured the old one.
Reconnect your cables and you’re good to go! Next, check out my Ender 3 mainboard upgrade guide—an upgraded mainboard gives you better prints while making your printer eerily silent.
Want to support Howchoo? When you buy a tool or material through one of our Amazon links, we earn a small commission as an Amazon Associate.


The Raspberry Pi 4 has been a hot topic since it’s release—and no one knows that better than Jeff Geerling. In a recent blog post, Jeff reveals a serious issue that’s impacting the performance of the Pi 4.
Be sure to also check out our guide on adding a Raspberry Pi fan that will turn itself on and off automatically!
Here’s everything you’ll need to complete this guide:
| Raspberry Pi 4 Model B | × | 1 | ||
| Official Raspberry Pi 4 case | × | 1 | ||
| Pi-Fan Raspberry Pi fan | × | 1 | ||
| Hole saw bit, 1-1/8″ | × | 1 | ||
| Cordless drill | × | 1 | ||
| Drill bit, 7/64″ | × | 1 |


The Raspberry Pi Foundation released an official Raspberry Pi 4 Desktop Kit. The kit comes with a new plastic case featuring holes for every port on the Pi 4, but nothing at all for ventilation. This project uses the official Raspberry Pi 4 case, though you can use any other case to accomplish this project as well.
Most Raspberry Pi models don’t need fans or heatsinks for everyday use—but the Pi 4 is another story. The CPU idles around 60°C. Running heavy processes can heat the board so much it hurts to touch. Too much heat will cause the CPU to throttle, causing serious performance issues.
Jeff revealed some telling images by photographing the Pi 4 with a thermal imager. Most of the heat appears to come from the USB-C power circuitry. Since the heat has nowhere to leave inside the Pi 4 case, he decided to install a fan. Here’s a quick breakdown of the project.


The Pi-Fan is attached to the top half of the Pi case. Drill a hole in the center using a 1-1/8″ hole saw. Be sure to smooth out the edges with a file or sandpaper.
Line the fan up with the newly drilled hole and mark the screw holes with a pen or pencil. When drilling the screw holes, you will need a 7/64″ drill bit. Smooth out the edges and remove any remaining plastic.


Place the fan inside of the Pi case with the “Pi-FAN” sticker facing up. Line up the fan and screw it into place.
Connect the fan’s red wire to GPIO pin 4 (5V) and the black wire to GPIO pin 6 (ground). The fan should receive power automatically when the Pi is booted.
If you’d like your fan to only run when needed (based on Pi temperature), check out our Raspberry Pi fan controller guide.
After installing the fan, you may want to initiate a stress test to see how it’s impacting the Pi. Jeff’s observation resulted in a lower temperature that kept the Pi 4 well under its throttling point by about 20°C. You can find more details on performing a stress test in his original post. Don’t forget to check out our guide on how to measure the core temperature of your Raspberry Pi.
In this video, Jeff breaks down everything you need to add a fan to the Pi 4. Don’t forget to check out the full post on Jeff Geerling’s website!
Want to support Howchoo? When you buy a tool or material through one of our Amazon links, we earn a small commission as an Amazon Associate.


Like dark themes? Me too! This short guide will show you how to add a dark theme to your OctoPrint (or OctoPi) interface.


Themeify is one of the most popular OctoPrint plugins.
Open OctoPrint Settings by clicking on the wrench icon.
Then, select Plugin Manager and click Get More….
Finally, search for and install Themeify. When prompted, restart OctoPrint.


Open Settings once more and select Themeify from the sidebar.
Make sure Enable theme is checked and select Discorded or Nighttime from the Theme dropdown.
Click Save. You’re done!
Want to support Howchoo? When you buy a tool or material through one of our Amazon links, we earn a small commission as an Amazon Associate.
We’re hiring. Write for Howchoo
We’re hiring. Write for Howchoo
We’re hiring. Write for Howchoo
We’re hiring. Write for Howchoo