performance.now() vs Date.now()

后端 未结 2 1188
刺人心
刺人心 2020-12-04 20:33

What is the difference between performance.now() and Date.now()?

Should I consider performance.now() as a replacement for

2条回答
  •  没有蜡笔的小新
    2020-12-04 21:19

    Date.now() returns the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC, performance.now() returns the number of milliseconds, with microseconds in the fractional part, from performance.timing.navigationStart, the start of navigation of the document, to the performance.now() call. Another important difference between Date.now() and performance.now() is that the latter is monotonically increasing, so the difference between two calls will never be negative.

    For better understanding visit the link.

提交回复
热议问题