var vs const vs let in JavaScript

When programming in JavaScript, developers have three main options for declaring variables: var, let, and const. Each of these options has its own advantages and use cases, and understanding the differences between them is crucial to writing efficient and effective code.


Var is the oldest way of declaring variables in JavaScript, and it has been around since the language’s inception. One of the most significant advantages of var is that it is globally scoped, meaning that variables declared with var can be accessed from anywhere in the program. However, this can also lead to unintended consequences, as variables declared with var can be overwritten or redeclared without generating any errors. Additionally, variables declared with var are not block-scoped, meaning that they can be accessed outside of their declared block.


Let is a relatively new addition to JavaScript, having been introduced in ES6 (ECMAScript 2015). Unlike var, variables declared with let are block-scoped, meaning that they can only be accessed within the block they are declared in. This makes let a safer and more reliable option than var, as it eliminates the possibility of variables being accidentally overwritten or redeclared. Additionally, let variables can be updated without being redeclared, making them more flexible than const variables.


Const, short for “constant,” is another ES6 addition to JavaScript. As its name suggests, variables declared with const cannot be reassigned once they have been declared. This makes const variables useful for defining values that should not be changed, such as mathematical constants or configuration values. Additionally, like let, const variables are block-scoped, making them safer and more reliable than var variables.

So, which one should you use?

The answer to this question largely depends on the specific use case. In general, however, the rule of thumb is to use const for values that should not be changed, let for values that can be updated, and var sparingly (if at all) due to its global and non-block-scoped nature.

It’s also worth noting that there is no single “best” way to declare variables in JavaScript. Each option has its own strengths and weaknesses, and developers should choose the option that is best suited to their specific use case.

In conclusion, understanding the differences between var, let, and const in JavaScript is crucial to writing efficient and effective code. By using the appropriate option for each variable, developers can write code that is reliable, flexible, and easy to maintain.

AngularJS vs BackboneJS vs EmberJS? What I decided and why?

I was researching for Javascript frameworks/libraries to use in my next project. I found three promising JS frameworks.

What I was looking for was that framework should be easy to learn and should be integrated in the project easily. Keeping in that mind I searched a little bit about each and went through some reviews. What I concluded I’d just say it in one line for each.

Backbone.js – You need to write lots of boilerplate code to get to work.

Ember.js – It has a steep learning curve.

Anguler.js – Just in between. Offers more than backbone and is easier to learn than ember.

So, that was it! I picked Angular for my next project since it was easier to learn and you don’t have to do a lot to get it working in your project. Since the project was new and the deadline was short, this was the requirement. So, I decided to go with Angular and I’m glad I made the right decision.

What’s your call? What you picked and why? I would like to listen in the comments.