Javascript class with closures patterns