DEV Community

Discussion on: Why function deceleration overrides

Collapse
 
larsklopstra profile image
Lars Klopstra ⚡

It's already explained but you are re-assigning your name variable (the string) to the function.

I'd do this:

// Good :D

const myName = 'Richard'; 

const logMyName = () => {
  console.log(myName);
}

/* 
This example below will throw an 
error because you can't re-assign 
a constant variable so use the 
one I wrote above :)
*/

// Bad :(

myName = () => {
  console.log(myName);
}