While this helps to explain the pattern, the reality is that you're unlikely to want to do these kinds of things in JavaScript. You are likely better off either using an object, Map or array for these types of profiles.
Aside: how do others feel about these "Programming concept/algorithm X in JavaScript" posts?