Let and var for variable declarations

Let and var for variable declarations

Let and var keyword for variable declarations, those two allows you to declare variables. Let see the difference.

Here we declare a variable called: careId using: let keyword and assigning 43.

let carId = 43; 

Now if we try to reference careIdbefore we declare it we get the error:

console.log(careId); // error!
let careId = 43; 

And that makes total sense. The program run from top to bottom and we try to use a variable that is not declared yet. But if we declare: carId using the var keyword and try to access carId we do not get an error.


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

Andrzej D.的更多文章

  • Behavior Driven Development Vol. 3

    Behavior Driven Development Vol. 3

    There are few alternatives to choosing a BDD framework. and we’ll also take a look at the very popular one, JBahave.

  • Behavior Driven Development Vol. 2

    Behavior Driven Development Vol. 2

    Below is a simple class of the application. The flight class has two sub-classes: EconomyFlight and: BusinessFlight.

  • Behavior Driven Development Vol. 1

    Behavior Driven Development Vol. 1

    Introduction Behavioral Driven Development (BDD) is a software development approach that has evolved from TDD (Test…

    2 条评论
  • DevOps - why you should care?

    DevOps - why you should care?

    Manual deployments are basically quicker at the beginning but in further, than can by harder to deploy a lot of…

  • Malicious software

    Malicious software

    Malware, short for malicious software, is an umbrella term used to refer to a variety of forms of hostile or intrusive…

  • Detailed VPN Comparison Chart

    Detailed VPN Comparison Chart

    Few days ago I found with comparison of VPN’s: The site is meant to be a resource for those who value their privacy…

  • Writing Tool for Software Developers

    Writing Tool for Software Developers

    Introduction As a software engineer you have spend a lot of time preparing your programming environment to boost…

  • Shodan Internet Exposure Dashboard

    Shodan Internet Exposure Dashboard

    Every one of us used a serach engine like: Google or Bing to find some interesting stuff on the Internet. Seach engines…

  • Business trips - basic field manual

    Business trips - basic field manual

    Travelling is most stressful, especially for business travellers. Sometimes travellers have habits that include an…

  • Short introduction to git

    Short introduction to git

    Working directory | working tree Catalog in which we make changes. It contains check out latest version in a current…

    2 条评论

社区洞察

其他会员也浏览了