As @pdenes pointed out in the comments, there has been some discussion on the topic here: https://plus.google.com/communities/104441363299760713736/s/Berriman%20new%20version%20fails
There's also a Douglas Crockford youtube talk called "The Better Parts" in which Douglas exposes some of his opinions on this, and proposes a (in his opinion) better way to make a constructor.
The proposed constructor pattern looks like this (directly taken from his talk, it also illustrates some features of ES6):
function constructor(specs) {
let {member} = spec,
{other} = other_constructor(spec),
method = function() {
};
return Object.freeze({
method,
other
});
}
The "pattern", as I understand it, is to avoid using "this" and any other way of object creation (by means of new, or Object.create), getting also rid of prototypal inheritance.
At this point, the constructor is now a function that returns an object (in this case, frozen, but there's no need for that actually).
All the "object-oriented" stuff is achieved by storing the members and methods in the constructor's closure, and member function can refer to those by name because they're present in the current scope. That successfully avoids the use of "this".
Sadly, the real answer I get from this is that there are many convoluted ways to create an object in javascript, and IMO each one has its flaws. JSLint is a nice tool, but no one should be following it without doing some research and understanding why are those errors given. Especially when no real, comprehensive reason is offered. Not even by the author.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…