The most interesting thing about the Javascript example is that it is exactly the same as the example of adding a dynamic method to a class. There is no difference because Javascript functions are closures. The ubiquity of closures in Javascript is extremely powerful and, makes metaprogramming very easy.