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

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

.htaccess - ERR_TOO_MANY_REDIRECTS htaccess -