JavaScript: Reverse Arrays

Manipulating data is core to any programming language. JavaScript is no exception, especially as JSON has token over as a prime data delivery format. One such data manipulation is reversing arrays. You may want to reverse an array to show most recent transactions, or simple alphabetic sorting. Reversing arrays with JavaScript originally was done via reverse but that would mutate the original array: // First value: const arr = ['hi', 'low', 'ahhh']; // Reverse it without reassigning: arr.reverse(); // Value: arr (3) ['ahhh', 'low', 'hi'] Modifying the original array is a legacy methodology. To avoid this mutation, we’d copy the array and then reverse it: const reversed = [...arr].reverse();... more →
Posted in: JavaScript

How to Reverse an Animated GIF

Modifying visual media via code has always been a fascination of mine. Probably because I’m not a designer and I tend to stick to what I’m good at. One visual effect I love is seeing video reversed — it provides a sometimes hilarious perspective on a given event. Take this reversed water effect for example: To reverse an animated GIF or video, you can use the ImageMagick library: convert water-forward.gif -coalesce -reverse -quiet -layers OptimizePlus -loop 0 water-reversed.gif If you’re interested in media engineering, check out my previous ImageMagick tutorials. These awesome media libraries are as close to an artist I will ever get! The post How to Reverse an... more →
Posted in: JavaScript