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
Post a Comment