I was asked to port some of our PHP code to JavaScript, so most of our logic works on the client side. What I would like is a simple example that shows:
- namespace ("Package") containing two classes ("Master" and "Slave")
- the master class has the p property, the m function, and a constructor that takes one argument to set the initial value of p
- class "Slave" inherits "p", constructor and "m" from class "Master"
I do not mind the use of some existing structure, but it should be light - ideally no more than 200 LOC (without restrictions).
Here is my attempt, FWIW:
var Package = {}; Package.Master = function(pValue) { this.p = pValue; this.m = function() { alert("mmmmm"); } } Package.Slave = function(pValue) {
source share