So I'm trying to find a really clean JavaScript function prototyping pattern.
I can do this:
var Person = function () {
// person logic
}.prototype.foo = function () {
// people's foo logic
}
but I want to name my class constructor without being redundant. The following code yield unexpected .
before the word prototype
.
function Person() {
// person logic
}.prototype.foo = function () {
// people's foo logic
}
How can I define my prototype on the same line without redundantly setting Person to a variable?