View Single Post
Old 11-23-2012, 10:57 AM   PM User | #2
Dormilich
Senior Coder

 
Dormilich's Avatar
 
Join Date: Jan 2010
Location: Behind the Wall
Posts: 2,863
Thanks: 9
Thanked 291 Times in 287 Posts
Dormilich is on a distinguished road
so what is your objective here, define a private method?

anyways, the naming of "child method" and "sibling method" does not really make sense. seen verbatim, every method of an object is a sibling method of the other. "child method" would only make sense if inheritance were involved (which isn’t).

if child method is meant to be that: testSingleton.myFirstMethod.childMethod();, myFirstMethod must be an object (and in this particular case not even a function), which has a childMethod() property. mind that childMethod() does not have a relation to testSingleton then.
PHP Code:
var testSingleton = {
    
myFirstMethod: {
        
childMethod: function() {}
    }
};

// alternately
var testSingleton = {
    
myFirstMethod: function() 
    {
        return {
            
childMethod: function() {}
        }
    }
};
// as
testSingleton.myFirstMethod().childMethod(); 
__________________
please post your code wrapped in [CODE] [/CODE] tags

Last edited by Dormilich; 11-23-2012 at 11:00 AM..
Dormilich is offline   Reply With Quote