A skilled software engineer, talented problem-solver and team player with a passion for using technology to solve complex problems and constantly seeking out new challenges to advance my skills👨🏼💻
I prefer array because if we use object, destructuring will be an issue if there is more than one block in same level. Also we need to be aware of the property name.
Graduated in Digital Media M.Sc. now developing the next generation of educational software. Since a while I develop full stack in Javascript using Meteor. Love fitness and Muay Thai after work.
Property name can be set by convention across your whole project. Let's say { error, result } which is to me most verbose and would not lead to accidental access compared to array indices
A skilled software engineer, talented problem-solver and team player with a passion for using technology to solve complex problems and constantly seeking out new challenges to advance my skills👨🏼💻
constresponseOne=awaitmethodOne();if(responseOne.error)returnconstresponseTwo=awaitmethodTwo();if(responseTwo.error)return// of if you want destructuringconst{error:methodOneError,result:resultOne}=awaitmethodOne();if(methodOneError)returnconst{error:methodTwoError,result:restultTwo}=awaitmethodTwo();if(methodTwoError)return
Im not saying the array descructuring is worse, its just a prefference
A skilled software engineer, talented problem-solver and team player with a passion for using technology to solve complex problems and constantly seeking out new challenges to advance my skills👨🏼💻
A skilled software engineer, talented problem-solver and team player with a passion for using technology to solve complex problems and constantly seeking out new challenges to advance my skills👨🏼💻
Nice, but I would personally use an object instead of the array as a return type
I prefer array because if we use object, destructuring will be an issue if there is more than one block in same level. Also we need to be aware of the property name.
Property name can be set by convention across your whole project. Let's say
{ error, result }
which is to me most verbose and would not lead to accidental access compared to array indicesYeah, that is right. But in case of multiple blocks in the same scope it can create issue, as you will not be able de-structure it like this
But in case of array, you can use other variable name in the second method call.
Feel free to correct me, if I am missing something.
a few ways you could avoid this:
Im not saying the array descructuring is worse, its just a prefference
You can rename the variable when destructuring an object.
@jsnanigans Yeah, It's just a preference.
@erikhofer I am aware of that.