There are two completely independent idioms that make the 2nd example more verbose:
The use of if instead of boolean operators for conditions. I tend to use if as the default and sometimes refactor when I think that the code is more readable when using a boolean operator. I also know some people who always use if and consider the other variant as a misuse of boolean operators.
The use of intermediate constants for function returns instead of function chaining. This can be useful for two reasons: You can use meaningful names for these constants that provide additional information about what is happening and thus make the code more readable. In this example, I would say that the names jsonStr and especially dataObj do not provide much useful information. Another reason not to chain function calls is to make debugging easier.
I personally have a certain bias towards compactness and like the 1st example slightly more. In real code, the optimum is probably somewhere in between.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
There are two completely independent idioms that make the 2nd example more verbose:
The use of
if
instead of boolean operators for conditions. I tend to useif
as the default and sometimes refactor when I think that the code is more readable when using a boolean operator. I also know some people who always useif
and consider the other variant as a misuse of boolean operators.The use of intermediate constants for function returns instead of function chaining. This can be useful for two reasons: You can use meaningful names for these constants that provide additional information about what is happening and thus make the code more readable. In this example, I would say that the names
jsonStr
and especiallydataObj
do not provide much useful information. Another reason not to chain function calls is to make debugging easier.I personally have a certain bias towards compactness and like the 1st example slightly more. In real code, the optimum is probably somewhere in between.