February 28, 2013
What does =+ mean in JavaScript
Question by dk89
I was wondering what the =+ operator means in JavaScript. It looks like it does assignments.
Example:
hexbin.radius = function(_) {
if (!arguments.length)
return r;
r = +_;
dx = r * 2 * Math.sin(Math.PI / 3);
dy = r * 1.5;
return hexbin;
};
Answer by mpm
Answer by Starx
It is not an assignment operator:
_
is just a parameter passed to the function+
infront as+_
casts that variable_
to a number or integer value
DO NOT CONFUSE IT WITH +=
operator