24 Mar
2014
24 Mar
'14
11:50 a.m.
When writing methods for a class, I generally use the following pattern: [1] ``` /** * APIdox */ function doSomething() { } this.doSomething = doSomething; ``` instead of [2]``` /** * APIdox */ this.doSomething = function() { }; ``` I prefer to do this even if `doSomething` is never used internally in the class. This is because if and when it becomes necessary to use this function within the class, I do not need to change too many lines by switching from [2] to [1]. I am also more comfortable with the C++ pattern in which public functions are expected to be simply callable just like a private function within the class. It would be nice to have a policy for this so we can have a consistent style. Thoughts?