JavaScript Variables

 JavaScript Variables:- 

variables are like containers for storing values

Declaring a variable:-

we can create a variable using "let" keyword

code : let greeting;

Assigning a Value:- we can put data into a variable using assignment operator(=)

code:

let greeting = "good morning";

             or

let greeting;

greeting = "good morning";


Note: if we print a variable without assigning a value will give "Undefined" as output.

code: 

let greeting;

console.log(greeting);

o/p :- undefined

code:-

let greeting;

greeting = "good morning";

console.log(greeting);

o/p:- good morning








Comments