On May 26, 11:48*pm, "Michael Haufe (\"TNO\")"
<t...@thenewobjective.com> wrote:
> On May 26, 1:57*pm, Aleksey Zhendi <a.zhe...@gmail.com> wrote:
>
>
>
>
>
>
>
>
>
> > Description:
> > * *JOOT is a small JavaScript library that provides convenient and
> > simple API designed for sole purpose: to simplify creation of the
> > object-oriented code.
>
> > Project URL:
> > * *http://code.google.com/p/joot/
>
> > Features:
> > ** Narrow purpose. No redundant API.
> > ** Simple and convenient API.
> > ** Fully based on the ECMAScript specification (ECMA-262 3rd edition)..
> > ** Respects ECMAScript 5 "strict mode".
> > ** No environment-specific code.
> > ** No external library dependencies.
> > ** Does not modify native objects.
> > ** Minimum probability of name conflicts. Adds only a single property
> > to the global context.
> > ** Small size.
>
> Yet another "OO" library.
>
> For easier review/consumption, could you provide an example of how
> your library would implement this:
>
> function Animal(){}
> function Cat(){}
> Cat.prototype = Object.create(Animal.prototype);
> Cat.prototype.constructor = Cat;
> Cat.prototype.myExtendedMember = function(){
> * * return "foo";
>
> }
>
> While maintaining the appropriate constructor and instanceof
> relationships.
>
> -----------------------------
>
> Does/can it handle private variables with inherited methods that have
> access to them?
>
> -----------------------------
>
> Does it make it simpler to declare "static" variables?
1) Yes of course:
var Animal = joot.createClass();
var Cat = joot.createClass( {
$parent: Animal,
myExtendedMember: function() {
return 'foo';
}
} );
var x = new Cat();
console.log( x instanceof Animal ); // true
console.log( x instanceof Cat ); // true
console.log( x.constructor === Cat ); // true
2) JOOT emulates inheritance by linking classes prototypes.
To emulate true private properties\methods we must declare them in the
constructor function with 'var' statement.
So they are stored in a closure, not in the class prototype.
So the answer is no.
3) Although it can be easily implemented, for now there is no any
'sugar' for it.