Question d’entretien chez Canva

Differences between let, var, const?

Réponse à la question d'entretien

Utilisateur anonyme

17 déc. 2020

Var 1 - Function Scoped 2 - Can be re-declared & updated 3 - Hoisted in the creation phase and initialized to = undefined ------------- Let 1 - Block Scoped 2 - Can be updated but not re-declared 3 - Hoisted in the creation phase but not initialized so when you try to access it before initialization you will get a Reference Error ------------- Const 1 - Block Scoped 2 - Can't be updated nor re-declared 3 - Hoisted in the creation phase but not initialized so when you try to access it before initialization you will get a Reference Error 4 - Must be initialized at the time of declaration 5 - Const Objects can't be updated but you modify inner properties