1 This is a tip of the hat to the weird history of javascript and the reluctance to do away with bad implementations. As we’ll later see, this is not as strict as we want it to be.

2 This is a secret handshake between the developer and the browser that this is a class .

3 This is the constructor, and it does nothing, but it can be modified in several steps below.

4 The prototype feels like you’re mucking with a meta object. Indeed, that’s how javascript wants you to deal with classes.

5 As you’ve probably noticed by now, there are no types to parameters or return values. Javascript does not impose any restrictions inspite of having classes we’ve seen earlier. The solution to getting type information in the IDE is use of JSDoc. You might be tempted to think there is Haskell style type inference. Do not fall for that trap. Things can go from bad to worse pretty soon once a method is called incorrectly.

6 There is no sane definition of this since classes are just functions. So what this means depends on where it is used. In this case, it’s an instance of FactorialUtilClassic . An experienced javascript developer would know this by instinct, but still fall for it’s traps.

7 Here we’re using lodash or underscore or some library that offers a functional style of programming.

8 This is the boilerplate required to call reduce

9 If you forget the return keyword, the function is assumed to return void . There is no warning.

10 This is a static function. The clue is, there’s no prototype .

11 this means the class over here.