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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That’s the
+unary operator. It’s equivalent to:See http://xkr.us/articles/javascript/unary-add and MDN.