How could I correct this behavior so this inside is.green refers to the new book(). Because I’m convinced there isn’t a way.
function book(){}
book.prototype.is = function(){};
book.prototype.is.green = function(){
alert(this);
// this should refer to 'new book' not `is` function
return this;
};
var Book = new book();
Book.is.green();
TLDR
Is there a way to construct an new prototype object for each new book that could hold the correct reference? Are there any other potential techniques?
or (I know you said you didn’t want to alter the constructor, but):
or (non-cross-browser):
What’s the point of this? Just to have the word “is” needlessly placed somewhere? What’s wrong with
Book.isGreen()?