+new Date() – Is this good practice?

The getTime method appears to be a huge amount faster:

enter image description here

Why is this the case?

Here’s what happens when you call the getTime method on a Date instance:

  1. Return the value of the [[PrimitiveValue]] internal property of this Date object.

Here’s what happens when you apply the unary plus operator to a Date instance:

  1. Get the value of the Date instance in question
  2. Convert it to a Number
    1. Convert it to a primitive
      1. Call the internal [[DefaultValue]] method

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)