# Binary Search: Useful Variants

|

Binary search is one of the most fundamental algorithms in computer science, and often one of the earliest taught algorithms in University (depending on major, of course). Alone, binary search lets us quickly determine the index of some value in a sorted dataset. If the value doesn’t exist, ideally it will return some sentinel value indicative of that. So in short:

# What is MutationObserver?

|

MutationObserver is a DOM API that allows us to react to changes in the DOM in a performant way. The MutationObserver constructor in JavaScript takes a callback function which gets called on each mutation you choose to observe. The callback is called with two parameters.

|

# Browser Cache Fundamentals

|

The browser cache is something I think a lot of developers know of but don’t understand well, primarily because many tools take care of it for us. For example, when building an application with Node.js the first thing many developers do is type:

# JavaScript "in" Confusion

|

The in operator, when used with arrays in JavaScript, comes with a little nuance and may be the cause of some confusion. The in operator is strictly used to tell whether a given property name exists in an object or its [[Prototype]] chain (and is enumerable, but we’ll cover that later). So how does this work for arrays? It’s tempting to think 2 is in [1, 2] but this will return false.