Is there a way to exploit the performance advantages of using prototype methods in JavaScript factory functions?
问题 I'm looking for the best way to write object-oriented JavaScript (JS) code in a way that is similar to Java classes. Factory functions (FFs) look like a very promising way of offering class-like functionality in JS and, so far, I've been building them like this: function FF(constructorArg) { var _privateName = constructorArg; var publicMessage = "Hello StackOverflow"; function publicMethodGetName() { return _privateName; } return { publicMethodGetName: publicMethodGetName, publicMessage: