Can you use the
This is the format for a sane
const today = new Date(); console.log(today); // 2019-08-23T09:31:12.181Z
If you want to pass parameters -
const firstDay = new Date(2019, 0, 1); console.log(firstDay); // 2019-01-01T00:00:00.000Z
This simply means that
firstDay is created by passing variables to
Date, which are in turn being used by the date constructor.
If you do not have any variables for date, the following code is valid.
// prettier-ignore const newToday = new Date; console.log(newToday); // 2019-01-02T00:00:00.000Z
The syntax without brackets is in fact valid for any object, not just date.
I was indeed surprised (and a bit hurt) that I never encountered this statement so far. The reason for that was far more logical - it turned out that Prettier does not like this syntax either and puts the brackets automatically.
Well, I did learn something that I may not possibly use for the rest of my life.