javascript - What does the plus sign do in '+new Date' -
i've seen in few places
function fn() { return +new date; }
and can see returning timestamp rather date object, can't find documentation on plus sign doing.
can explain?
that's + unary operator, it's equivalent to:
function(){ return number(new date); }
see: http://xkr.us/articles/javascript/unary-add/
and in mdn: https://developer.mozilla.org/en-us/docs/web/javascript/reference/operators/arithmetic_operators#unary_plus
Comments
Post a Comment