The difference between function, var, and let/const.

function myFunc(){}
var myFunc = function() {};
const myFunc = () => {};

function 🔑

console.log(add(1, 2)); // 3function add(a, b) {
return a + b;
}

var 👛

console.log(add); // Uncaught ReferenceError: add is not defined
console.log(add); // undefined
var add = function(a, b) {
return a + b;
};
console.log(add); // Function
let add;
console.log(add); // undefined
add = function(a, b) {
return a + b;
};
console.log(add); // Function

let/const 🥇

console.log(add); // Uncaught ReferenceError: add is not defined
const add = function(a, b) {
return a + b;
};
console.log(add); // Function

Conclusion 🔚

Senior front end engineer / charlesstover.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store