javascript - How come "minus, space, minus" evaluates to the "plus" operator? -
node -e 'console.log(- -1)' // prints 1 makes sense
however:
node -e 'console.log(1 - - 1)' // prints 2 not make sense me
integer - - integer
magically converts "minus, space, minus" "plus" operator. why?
update: seems wasn't clear enough. question not why double negative in mathematics evaluate positive
how magically evaluates +
operator; these 2 different scenarios - making negative number positive 1 thing, invoking implicitly +
thing.
makes perfect sense, double negative in mathematics evaluate positive
Comments
Post a Comment