Javascript "let" & "const"

Javascript "let" & "const"

  • Variables declared with var are read/write but exhibit some unexpected characteristics, especially for developers coming from c+ +, java and c#.
  • Because of this confusion and other reasons, two new keywords( let and const) for declaring variables were added in es2015
  • Declaring variables with let and const behave as most developers expiated
  • Variables are defined within a block scope and there is no hoisting.
  • Variables defined with cost are immutable, while variables defined with let are mutable.
  • When declaring variables, always prefer const to let, unless there is a specific reason for a variable to be mutated.

要查看或添加评论,请登录

Allanki Srinivas (He/Him)的更多文章

社区洞察

其他会员也浏览了