Should I use an empty property key?

前端 未结 5 755
名媛妹妹
名媛妹妹 2020-12-13 08:18

I\'ve tested this only in Firefox, but apparently you can use an empty string as a key to a property in an object. For example, see the first property here:

         


        
5条回答
  •  攒了一身酷
    2020-12-13 08:52

    Is "unknown status" a null value or is your status field "not null"?

    In the first case I'd say you will have to use a separate counter, in the second I'd say that "empty" is a perfectly valid status - just use the word "unknown" for output instead of "". This might only lead to confusion when your user uses the same word as a status type, but to prevent that you only can use a different visual style for "unknown status" output text.

提交回复
热议问题