2

I'm implementing a class template like this:

function Class() {
    var _class = function () {
        console.log("init");
        this.init.apply(this, arguments);
    }

    _class.prototype.init = function () { };
    return _class;
}

var Person = new Class;
var person = new Person("alice");

and I'm trying to figure out how _class is being called. Nothing I can see is calling init so why is it executing?

sircodesalot
  • 11,231
  • 8
  • 50
  • 83
  • 2
    Oh crap. That makes total sense. – sircodesalot Jun 12 '13 at 21:54
  • http://stackoverflow.com/questions/3750082/javascript-oop-best-practices/13074081#13074081 – Brett Weber Jun 12 '13 at 21:56
  • 1
    @BrettWeber you should really provide some context for those links. This is the second time today I've seen you link to your answer from another question with absolutely no information scent. – Evan Davis Jun 12 '13 at 21:58
  • I'll keep it in mind, I'm working and looking for information so I haven't spent much time to slow down and explain much. – Brett Weber Jun 12 '13 at 22:00
  • @BrettWeber You can make a human readable link in a comment like this: `[Check out this similar answer which may help!](http://stackoverflow.com/questions/3750082/javascript-oop-best-practices/13074081#13074081)` (becomes [Check out this similar answer which may help!](http://stackoverflow.com/questions/3750082/javascript-oop-best-practices/13074081#13074081)). – Andrew Clark Jun 12 '13 at 22:02
  • AH! that works. Appreciate the tip. Again, hadn't slowed down to think about it. thanks – Brett Weber Jun 12 '13 at 22:04

0 Answers0