Thank you for your interest in Obsidian! Please enter your information in the form and we will contact you shortly to schedule a demo.
Since Javascript upgraded to ES2015, I have frequently seen many developers defaulting to arrow functions instead of normal functions.
// traditional function
function(x) {
return x * x;
}
// arrow function
x => x * x;
My critique is that people use them without asking why. I assume that it happens because it’s the cool way to write Javascript since it’s a newer feature than the regular functions.
Using React jsx with functional components.
// a bit longer and more cryptic.
const Input = ({ num }) => { var dup = num * 2; return <>{dup}</> };
// a bit less characters and it can hoist
function Input({ num }) { var dup = num * 2; return <>{dup}</> }
An example with an array map
// have to declare function before calling it
const duplicate = x => { var res = x * 2; return res; };
[1,2,3].map(duplicate);
// vs
// Regular functions hoist.
// I consider this easier to read since you first see the
// named function identifier and bellow you can optionally
// look at the definition.
[1,2,3].map(duplicate);
function duplicate(x) { var res = x * 2; return res; }
Named functions are easier to read (less cryptic), easier to debug because they appear in the call stack with their name instead of “anonymous”, they also appear named in the performance audit report.
Put some thought when you use a feature in a programming language. Not just because that’s how the 😎“cool kids” do it you should always do it like that. Tools have their optimal use-cases. If you are writing code for a team you should consider the optimal implementations.