I have some text in an object’s property. I’m testing to see if the object’s property has text in it to display; if it doesn’t then I display “-” instead of just a blank. It doesn’t seem like there’s a difference between:
if (MyObject.SomeText && MyObject.SomeText.length) { ... }
if (MyObject.SomeText && MyObject.SomeText.length > 0) { ... }
Are there any edge cases where one syntax would be preferable to the other?
they give same result. Btw, if its “text”, then
if (MyObject.SomeText)is enough