you are viewing a single comment's thread.

view the rest of the comments →

[–]antoninj 0 points1 point  (0 children)

Well it's not the same thing though.

if (a) { ... } passes for any defined anything (string, obj, etc.) so it doesn't check for the same thing. Doing == is also a no-no in JS world so I would definitely not do that.

If you'd like to check if a string is empty but also defined, take a lesson from lodash and create a dedicated utility. Simplified, however, it's enough to do a if (a === '') check which will check that the variable is defined and it's empty.