Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Foo(){};
- Foo.prototype = function() {
- function private() {};
- function public() {};
- function protected() { };
- return {
- public : public,
- protected : function () {
- if (!(this instanceof Foo)) {
- protected();
- } else {
- throw new ReferenceError("protected is not defined");
- }
- }
- };
- }();
- function Bar(){};
- Bar.prototype = function() {
- var p = Foo.prototype;
- p.protected();
- p.test = function() {
- p.public();
- }
- return p;
- }();
- var b = new Bar();
- b.test();
- b.protected();
Add Comment
Please, Sign In to add comment