JavaScript Variables and Bindings

Vin Andros
1 min readJan 30, 2021
Photo by Joshua Aragon on Unsplash

To catch and hold values, JavaScript provides something called binding or variable. This is used to handle program’s internal state, because we can used values, but to successfully create a program we have to save that values and complete operations in a most complexity level.

In modern JavaScript we have to special keyword to define a value, let and const, Let’s explain each of them:

Let

The let is used it to hold values that will change over the time,also you can define the binding without the value, but when you are going to used it, you will get an undefined. As well, you can declare more than one value at the time. Let’s see some examples:

let firstCounter = 5, secondCounter;
console.log(firstCounter)
//output -> 5
firstCounter = 1;
console.log(firstCounter)
//output -> 1
console.log(secondCounter)
//output -> undefined

Const

The const is used it to hold constants values,but you have to assign a value otherwise you will get and error, let’s see:

const thirdCounter = 3, fourth;
//output -> Error;
const fifthCounter = 5, sixthCounter = 6;
console.log(fifthCounter);
//output -> 5
fifthCounter = 15;
//output -> Error

if you want to know a litter more, check out this links Eloquent JavaScript and MDN Web Docs Variables.

--

--

Vin Andros

Passionate reading || Coding Addicted || FullStack Web Developer from Costa Rica