In this blog we are going to learn basic fundamentals of programming. We are exploring variables and datatypes in javascript.
First we try to understand variables. So what are variables.
Variables : Variables are containers that stores and manage some data.
There are three ways to declare a variable in javaScript. let , var and const .
syntax to declare a variable :
let variableName = value ;
Enter fullscreen mode
Exit fullscreen mode
var variableName = value ;
Enter fullscreen mode
Exit fullscreen mode
const variableName = value ;
Enter fullscreen mode
Exit fullscreen mode
You can use let , var and const according to your use case.
What is scope : Scope defines where a variable can be access in program.
Global Scope : A variable declared outside any function can be access anywhere in the program.
Function Scope : A variable declared inside a function cannot be accessed outside that function.
Block Scope : Block scope was introduced in ES6.
Variables declared with let and const can only be…