I searched for a methode to create a random hex color in JavaScript.
What I found was this: '#'+(Math.random()*0xFFFFFF<<0).toString(16);
I found this here.
I don't like to copy code I don't understand. I think I got everything except one tiny detail. This part right here: <<0
. It's in there to cut all numbers after the point by moving the binary code to the left by "0". But why does it cut the numbers? If I use a binary calculator and input something like 13 and 13.2, it gives me the same result. So what does moving the whole thing by 0 cut the point numbers?
I created a fiddle to demonstrate what I mean:
https://fiddle.jshell.net/ucjb3quL/
I hope you can help me