tnhu / jsface

Small, fast, elegant, powerful, and cross platform JavaScript OOP library. Support main(), singleton, super call, private, mixins, plugins, AOP and more.
MIT License
301 stars 46 forks source link

Inherit from javascript function #38

Open lcnvdl opened 8 years ago

lcnvdl commented 8 years ago

Hi! I'm using jsface for the new objects of my project, but I have a lot of "legacy objects", like:

var Robot = function() {

    this.getRotation = function() { return 0; }

};

I'm trying to create a child of Robot using jsface, like:

var RobotChild = Class(Robot, function() {
    return {
    };
});

But, when I do:

var robot = new RobotChild();

I get an empty instance.

Regards

tnhu commented 8 years ago

What do you mean you get an empty instance? I run the snippet, robot does have properties:

typeof robot; // "object"
typeof robot.getRotation; // "function"
robot.getRotation(); // 0