Any specific reason to not use const and let in the global scope? My introduction to JavaScript was in a college class and the instructor almost exclusively used let while now I'm using Codecademy online to learn more and it, at least so far almost exclusively used const unless there it plan to change it in which case it uses let. I don't think I've ever actually used var.
It depends on how complex your function is. If it's a few lines then there's no problem, but if it's a hundred+ line behemoth which returns a complex object then you want to declare your variables in the scope that you need them (using let instead of var).
3
u/[deleted] May 04 '20
Any specific reason to not use const and let in the global scope? My introduction to JavaScript was in a college class and the instructor almost exclusively used let while now I'm using Codecademy online to learn more and it, at least so far almost exclusively used const unless there it plan to change it in which case it uses let. I don't think I've ever actually used var.
Edit: changed a word