javascript - How to detect if a function inside a constructor was called as an constructor -
so have created function checks if called constructor:
{ this.x = function() { if (!this instanceof x) { return new x; } ... } }
but want have function inside should called constructor
{ this.x = function() { if (!this instanceof x) { return new x; } this.y = function(){ if (!this instanceof y) { return new y; } } } }
however, when try this, typeerror:
uncaught typeerror: right-hand side of 'instanceof' not object
how can check if function y
called constructor?
thanks in advance
Comments
Post a Comment