Can you use the Date
object without brackets? Yes, apparently - to a friend’s delight and my chagrin. I should know better than to rely on my somewhat shaky Javascript knowledge.
This is the format for a sane Date
code..
|
|
If you want to pass parameters -
|
|
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.
|
|
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.