javascript - The new Operator -


is possible write javascript function follows (valid) typescript interface:

interface foo{     // constructor:      new (): string;  } 

i.e. when called new operator returns string. e.g. following not work.

function foo(){     return "something"; }  var x = new foo();  // x foo (and not string) whether or not :)  

you should able do:

function foo(){     return new string("something"); }  var x = new foo();   console.log(x); 

you can return object, literals don't work. see here: what values can constructor return avoid returning this?


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -