I've written the following "class" in javascript:
var On = {
Request: {
User: function() {
_Login = function() {console.log('Let me see.')};
}
},
User: function() {},
Article: function() {},
Comment: function() {}
};
On.User.prototype = {
constructor: function() { On.Request.User.call(this)},
Create: function(username, password, email) {
username = username || null;
password = password || null;
email = email || null;
//here I want to call _Login from Request.user
},
Login: function(username, password) {
username = username || null;
password = password || null;
},
Reminder: function(username, email) {
username = username || null;
email = email || null;
}
};
...
var x = new On.User();
x.Create();
How could I inherit in User
function from Request.User
? I've tried it in many different ways but can't make it work (even made a constructor in User's prototype). How could I make it possible to inherit, and call _Login
from Login
?
Ps.: this code is just an example, I'm newbie to prototype, and trying to learn it via examples I write.