Posts

Showing posts from March, 2019

Difference between var,const and let in JavaScript

Image
Hello guys, In this post I will talk about the difference between var,const and let features used in JavaScript for variable declaration and how we can use them for coding.First we will talk about the var feature which is what most people are usually more familiar with. VAR Var declarations basically have 2 types of scopes.Global scope and function/local scope.If the variable is globally scoped it can be only accessed globally(cannot be accessed inside functions).If the variable is declared inside a function the variable can only be accessed from inside the function. Now let's look at an example to understand this more clearly. Here "object" is global scoped and "object2" is function scoped.Therefore the console output would be an error saying object is undefined. Now that we understand  the scope of Var lets look at two basic features of it. Var variables can be re-declared and updated Var variables can be re-declared and updated in the same s