Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

2
  • 4
    (Rephrasing my comment) Your code has a problem: it executes Date.now method instead of checking its support first. On older browsres it will cause Date.now is not a function error. Commented May 7, 2015 at 9:18
  • Perhaps a better alternative would be to use a ternary operator to assert that Date.now actually exists (and is a function), before attempting to invoke it: currentTime = typeof Date.now === "function" ? Date.now() : +new Date(). Commented Apr 4, 2018 at 14:54