On the server, I serialize my objects and sometimes, some properties are null. On the page, when I parse the string, the null properties are deserialized correctly and in my javascript, I test to see if the properties for which there might be a null are indeed null or not before working with them; like this:
if (TheObject.TheProp && TheObject.TheProp.length) {...}
It doesn't crash and it works. My question is this: should I, on the server, populate every property with something (ie. "" for strings and 0 for numbers) because it's considered good practice or is it ok to have null properties on the page?
Thanks for your suggestions.
nullthen it's most semantical to keep itnull. JSON has anullvalue after all; I don't see what advantage an empty string has.""is two characters shorter thannull, but in my opinion there's a significant semantic difference between an empty string andnull; at least, there certainly can be.