vendredi 6 janvier 2017

What does Reflect.construct let us do that wasn't doable before?

I'm trying to find a good reason to use Reflect.construct to achieve something noteworthy that I could not achieve before.

I'm not looking for an answer like the one here, because that example don't seem to be very useful. For example, why would I write

function greetingFactory(name) {
  return Reflect.construct(Greeting, [name]);
}

when I can just write

function greetingFactory(name) {
  return new Greeting(name);
}

?

Do you know any notable use cases for Reflect.construct?





Aucun commentaire:

Enregistrer un commentaire