What’s the best way to convert a number to a string in JavaScript?

like this: Actually, even though I typically do it like this for simple convenience, over 1,000s of iterations it appears for raw speed there is an advantage for .toString() See Performance tests here (not by me, but found when I went to write my own): http://jsben.ch/#/ghQYR Fastest based on the JSPerf test above: str = num.toString(); It should be … Read more

Long vs Integer, long vs int, what to use and when?

Long is the Object form of long, and Integer is the object form of int. The long uses 64 bits. The int uses 32 bits, and so can only hold numbers up to ±2 billion (-231 to +231-1). You should use long and int, except where you need to make use of methods inherited from Object, such as hashcode. Java.util.collections methods usually use the boxed (Object-wrapped) versions, because they need to work for any Object, and … Read more