javascript - How to access the prototype object from another object within it -


my knowledge of prototypes still in infancy, please bear me. have main object initialised via var book = new book();

i initiate prototype functions:

book = function(){     this.init(); }  book.prototype.init = function() {     //etc. } 

and initialise object:

book.prototype.bookmarks = {     init : function(){         //how can access book function?     } } 

i mean use book.somefunction() i'm curious if there's way access top level object. sorry if stupid question, i'll try , clarify unclear. thanks

no, not automatically. is, have tell subobject top object is, in init function of book, you'd this:

init = function() {     // create bookmarks instance , assign property of book.     this.bookmarks = new bookmarks();     // tell bookmarks me, book object.     this.bookmarks.book = this; } 

Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -