4 ms·
> Whenever you program in ECMAScript2016("Javascript"), you should take advantage of its features. That's a trap, I should rather make my code as readable, sca
by twii 9y ago
> Whenever you program in ECMAScript2016("Javascript"), you should take advantage of its features.
That's a trap, I should rather make my code as readable, scalable and bug free as possible regardless of ESxxx.
I can refactor in 10 other ways (different styles) coming to the same result, but that's not what my point was about. Using promises and so is just taste or preference, if you like it you use can it, if not do without. I've seen amazing spaghetti with promises and callbacks as well.
Easy to nitpick btw:
you compare err != null?? besides not using strict mode, what should err be? a String? So, what will happen if err is undefined or an empty String?
Then you call logFsResult with err while it is not used.. Did you even consider what happens if the value of type is not available in map_action? I'll be the end of the feast!
last one: True and False as an object key are not Booleans, so if you have your IDE up and running, the code will fail.
Now, you can try to solve this with promises, just as you can try brush your teeth with a broomstick.
- flavio81 9y ago> you compare err != null?? besides not using strict mode, what should err be? a String? So, what will happen if err is undefined or an empty String? YOU are the one who made that comparison, not me. You originally wrote the following line: ( err ) ? console.err( msg ) : console.log( msg ); What do you think the "?" operator does with "err"? > Then you call logFsResult with err while it is not used.. It seems you don't understand the code. I'm not calling "logFsResult", i am defining a function called logFsResult. You also did the same, you defined logFsResult to receive the "err" parameter. function logFsResult( type, err ){ var msg= ''; switch ( type ) { > That's a trap, I should rather make my code as readable, scalable and bug free as possible regardless of ESxxx. ES6 allows you to write more readable code than ES5. Take a look at the features.