Menu

Back to the front page

Using React with Babel and Webpack Hot Module Replacement Middleware

If you're developing a web application using React and ES6/ES2015, you may have cursed at the computer or impatiently tapped your fingers while waiting for files to compile and then having to manually reload the browser to see the latest changes. I used to use Gulp to help streamline…

Performance Differences for Inserting Into an Array

I was bored and curious and decided to compare the performance among different ways of inserting an element into the middle of an array. I tried three methods: Using Array.splice() Using Array.slice() and Array.concat() Using the ES6 rest operator The winner was using the combination of Array.…

ES6 Promises: Best Practices

After using more and more promises lately, I've gathered a handful of good and bad design patterns for promises. I'm going to list out some examples of how promises are typically used and demonstrate anti-patterns and how to clean them up. Like everyone, I've been guilty to some of these…

String Compression and Concatenation Performance

Here is a whiteboarding problem that may come up in interviews. You are given a string. Implement a function to perform basic string compression using the counts of repeated characters. For example, the string aabcccccaaa would become a2blc5a3. If the "compressed" string would not become smaller than the original string,…

Tree Traversal

BFS vs. DFS When you need to search or traverse a graph or tree-like structure, there are two common algorithms: breadth-first search and depth-first search. Which algorithm to use really depends on the structure of the tree and the location of the items you need to find. Here are some…