Possible Duplicate:
What is the “double tilde” (~~) operator in JavaScript?
The D3 tutorial gives a function that produces a random sequence:
var t = 1297110663, // start time (seconds since epoch)
v = 70, // start value (subscribers)
data = d3.range(33).map(next); // starting dataset
function next() {
return {
time: ++t,
value: v = ~~Math.max(10, Math.min(90, v + 10 * (Math.random() - .5)))
};
}
Note the ~~ (tilda tilda) in:
value: v = ~~Math.max(10, Math.min(90, v + 10 * (Math.random() - .5)))
From playing around in the javascript terminal, I see:
~~1
1
~~-1
-1
~~-1.3
-1
parseInt(5)
5
parseInt(-5)
-5
parseInt(-5.3)
-5
parseInt(5.3)
5
Since ~~ and parseInt seem to be equivalent, whats the rationale for using parseInt?