JavaScript Variables

sunitha hegde
1 min readJun 17, 2021
JS Variables

Js varibales are used to store data ,data can be any type like it may be number,string,boolean…etc
The data or value stored in the variables can be set, updated, and retrieved whenever needed.

// Declaring Variable
var userName;

// Assigning value
userName = “The Hegde”;

var a = 4 ; //assigining integer type data to the variable “a”
var b = “The Hegde” ; //assigining string type data to the variable “b”
var c = true ; //assigining boolean type data to the variable “c”

Note: In JavaScript, if a variable has been declared, but has not been assigned a value explicitly, is automatically assigned the value undefined.

Types of Variabales:

  1. var , 2.const , and 3 .let
    Before the ES6 version of javascript, only the keyword var was used to declare variables. With the ES6 Version, keywords let and const were introduced to declare variables.

Diffrence between var ,const and let.

var /const/et

--

--