Why does DoubleClick's floodlight tag cast a variable to a String and the to a number again?

908 Views Asked by At

The JS implementation of DoubleClick's floodlight tag looks something like this:

<script type="text/javascript">
var axel = Math.random() + "";
var a = axel * 10000000000000;
document.write('<iframe src="https://123.fls.doubleclick.net/(snip);ord=' + a + '?" width="1" height="1" frameborder="0" style="display:none"></iframe>');
</script>

Interestingly, to get the random impression ID (the parameter ord), the var axel is fist coerced into a string, then back into a Number a and lastly back into a string when the iframe's src attribute is being constructed. Why is this done in this way? What's the difference to just using

var a = Math.random() * 10000000000000 + "";
0

There are 0 best solutions below