Start a new topic

Objects created by reflection are of the wrong type

Hey there,

I ran into a problem with objects created like in the Reflection Live Demo.

The Person object created by invoking the first constructor is not of type Person (at least not really). If you run the Chrome debugger without source maps, you can see that instance is a "object" and not the well defined "Person" as it would be if you create it with new Person(...). (see the differences in the attached images)

1 Comment

It's not a bug, both instances are Person actually.

You can easily check it with is operator like "is Person" or even GetType() == typeof(Person) in both cases these are true.

The reason you don't see Person in the second case is related to "dynamic" new operator using

  var instance = Object.create(this.jsConstructor.prototype);

  this.jsConstructor.apply(instance, parameters);

and it's know named functions "issue" and it's related to JavaScript engine and Chrome.

For more info you can read this:

Login or Signup to post a comment