8000 Static of father becomes normal member in child · Issue #5 · DominikGuzei/Class.js · GitHub
[go: up one dir, main page]

Skip to content

Static of father becomes normal member in child #5

6EAC
Open

Description

@centurianii

function Person(name){
this.name = name;
}

//Class Dreamer extends Person
var DreamerC = Class('Dreamer', {
Extends: Person,
STATIC: {
sleep: true,
dream: 'who knows'
},
initialize: function(name, dream) {
//Explicit call to Dreamer.Super === Person
Dreamer.Super.call(this, name); //or DreamerC ???
this.dream = dream;
}
});
//var dreamer = new Dreamer('Dreamer', 'zzZZZ...I'll change the world today!');
//dreamer.wakeUp();
//console.log('dreamer.sleep=' + dreamer.sleep + ', Dreamer.sleep=' + Dreamer.sleep);

//Class Scientist extends Dreamer
var ScientistC = Class('Scientist', {
Extends: Dreamer,
STATIC: {
sleep: false
},
initialize: function(name, dream, science) {
//Explicit call to Scientist.Super === Dreamer
Scientist.Super.call(this, name, dream); //or ScientistC ???
this.science = science;
}
});
var super_wakeUp = Scientist.Super.prototype.wakeUp;

var scientist = new Scientist('Scientist', 'zzZZZ...I'll change the world today!', 'Nuclear');
console.log('Error: scientist.sleep=' + scientist.sleep + ', Ok: Scientist.sleep=' + Scientist.sleep);
console.log('Ok: scientist.dream=' + scientist.dream + ', Ok: Scientist.dream=' + Scientist.dream);

Reports:

Error: scientist.sleep=true, Ok: Scientist.sleep=false
Ok: scientist.dream=zzZZZ...I'll change the world today!, Ok: Scientist.dream=who knows

My Evaluator test page: https://github.com/centurianii/g3OO

PS: the whole namespace thing is very frustrating I think: 1. one identifier for your namespace, 2. another identifier catches the function-constructor, 3. another identifier is used to represent the actual object... hmmmmm
My-class just bypass step 1 and uses everywhere, even inside the constructing object, the identifier from step 2.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0