The getTime
method appears to be a huge amount faster:
Why is this the case?
Here’s what happens when you call the getTime
method on a Date
instance:
- 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:
- Get the value of the
Date
instance in question - Convert it to a Number
- Convert it to a primitive
- Call the internal
[[DefaultValue]]
method
- Call the internal
- Convert it to a primitive