In a lecture called "The Way Forward", Douglass Crockford shares that he no longer uses "new" in his JavaScript, and is weaning himself off of "this&quo
The purpose of the assignment is to make the method "public". Without this assignment, the method is "private" to the "class".
Maybe i can try to make the code more understandable :
function constructor(init) {
// Call the mother constructor. Or just do that = init.
var that = other_constructor(init);
// Private members
var member1, member2;
// Methods
var method1 = function() {
do_stuff();
};
var method2 = function() {
do_stuff();
};
// Make some method public.
that.method1 = method1;
return that;
}
Then in you code, you can use your constructor like this :
var obj = constructor(other_obj);
obj.method1();