What does the plus sign do in '+new Date'

javascript, syntax

Solution

That's the `+` unary operator. It's equivalent to:

function(){ return Number(new Date); }

See http://xkr.us/articles/javascript/unary-add and MDN.

Problem

I've seen this in a few places ``` function fn() { return +new Date; } ``` And I can see that it is returning a timestamp rather than a date object, but I can't find any documentation on what the plus sign is doing. Can anyone explain?

Original source

Related problems