News for hackers. Stuff that matters.
Re:Be careful with JS numbers by crazygringo on Sunday January 13, 2013 @02:48PM (#5051642)
Essential rule: ALWAYS treat large ID numbers in JSON as strings. Produce them as strings on the server, so the browser treats them as strings during the JSON decoding process.

(Fortunately, if they're ID's where they need to stay exact, then you probably don't need to do any math on them! Although once a coworker of mine had to write a bitwise XOR function in JavaScript that operated on large ID numbers represented as strings. That was fun...)

Re:Be careful with JS numbers by Joeri on Sunday January 13, 2013 @04:52PM (#5052018)
Been burned by this myself, because while the person that created the ID knew it was a string, the person using it down the line thought it looked like a number and treated it like one.

My advice is to store those ID's with a leading "$" character or something similar. Removes the temptation to treat them like numbers.

Re:Be careful with JS numbers by ewang1 on Sunday January 13, 2013 @09:43PM (#5053032)
Or convert them to hex before sending to client. And you can convert them back to decimal on the server side.