Hi all,
I’ve been formatting my function expressions and anonymous functions a bit differently than how they are usually presented everywhere (be it freeCodeCamp, books, websites etc.).
The reason I do this is because I find my way of formatting much easier to read but am concerned that by doing this I’m developing bad habits since I should really learn to read the code in the more conventional formatting.
Any feedback from the community would be greatly appreciated, thanks in advance.
The example I give below (no spoilers here) are from the starting code of " Write Arrow Functions with Parameters" in the ES6 part of the curriculum, link: https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/es6/write-arrow-functions-with-parameters
My preferred format:
var myConcat = function(arr1, arr2) {
return arr1.concat(arr2); // I like to indent here.
};
console.log(myConcat([1, 2], [3, 4, 5]));
Usual format everywhere else (standard format):
var myConcat = function(arr1, arr2) {
return arr1.concat(arr2);
};
console.log(myConcat([1, 2], [3, 4, 5]));
I see maybe one possible drawback to how I format the code, and that is the standard format is closer to how the arrow function looks (I stick to conventional formatting for arrow functions):
const profileUpdate = (profileData) => {
const { name, age, nationality, location } = profileData;
}
So are there any drawbacks to how I format function expressions and anonymous functions? Should I just stick to conventional formatting? I guess ultimately what I want to know is, how come it seems no one formats it the way I like yet it seems much more readable?
Thanks everyone.