return the named function constructor instance with new operator - Javascript Object

Javascript examples for Object:Constructor

Description

return the named function constructor instance with new operator

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){/*from w  w w.ja v a 2 s. c o  m*/
var foo = function () {
    return new moo();
}
var moo = function () {
    return this;
}
var myFoo = new foo(2);
if(myFoo instanceof moo){
    console.log("moo");
}
if(myFoo instanceof foo){
    console.log("foo");
}
    }

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials