SolidJSS
SolidJSโ€ข2y agoโ€ข
2 replies
Eatham

Difference between using `const` and `function` to declare a function

I am relatively new to JavaScript and in my time learning I have noticed that people decalare their functions/components using const and also function.

E.g. Using function
function MyComponent(props) {
return <div></div>;
}


And using const:
const MyComponent = (props) => {
return <div></div>;
}


What are the differences between the two and why would I use one over the other? Thanks ๐Ÿ™‚
Was this page helpful?