how would you pass in parameters to a constructor when written like new(Date)?

StackOverflow https://stackoverflow.com/questions/8236220

  •  06-03-2021
  •  | 
  •  

Вопрос

As a corollary to this question, if you created an object in javascript using the syntax new (Date) how would you pass in any constructor args/params?

In other words is there an equivalent of new Date(2000) or is that just how you would do it?

Это было полезно?

Решение

The parens return the result of the contained expression, so this will work:

new (Date)(2000);

This is the same as:

new Date(2000);

Другие советы

Have you tried: new (Date)(2000)? Not exactly pretty code...

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top