3 ms·
> Note that we did not use a lot of confusing JS stuff: no this, no new, no prototype Makes as much sense to me as it did to you. That is, very little. I wish
by chrisbroadfoot 15y ago
> Note that we did not use a lot of confusing JS stuff: no this, no new, no prototype
Makes as much sense to me as it did to you. That is, very little.
I wish the author would properly explain why he went to great lengths to avoid the tools available to him.
- TazeTSchnitzel 15y agoI don't know the author's reasoning, but I read Crockford's JavaScript: The Good Parts, which demonstrates several OOP styles (including this one). One of the reasons he likely didn't use the "this" keyword is because it's compromisable. "this" is anything that the invoker of the method wants it to be, so you can accidentally compromise information. Also, if you have your variables in function scope and the function is created in that scope, the keyword is unnecessary. Regarding not using new/constructor functions, some people think the non-constructor-based OOP model in JS is nicer. Finally, regarding lack of prototypes, if you want to keep secrets then you can't re-use functions. On the other hand, if you are creating public/non-privileged methods, no reason not to re-use functions.