How to Declare Variables in JavaScript

Free Web development courses with real-time projects Start Now!!

Program 1

// Declare a variable
/* 
     Dynamic Declartion (Auto)
     var
     let
     const 
*/
// Dynamic Declartion (Auto) 
// a=10
// console.log(typeof(a))
// a="Hello"
// console.log(typeof(a))
// a=true
// console.log(typeof(a))

// var


//    var a=100   //global
//    console.log("Inside Type:"+typeof(a))
//    console.log("Inside value :"+a)

// var a="Hello Friends"  //Redeclare
// console.log("Outside Type :"+typeof(a))
// console.log("Outside  Value:"+a)


// Let

//     let a=100  // Local 
//     console.log("Inside Type:"+typeof(a))
//     console.log("Inside value :"+a)
//    let a="Hello Friends"  //Redeclare
//    console.log("Outside Type :"+typeof(a))
//    console.log("Outside  Value:"+a)

// var a=100  // variable
// console.log("Type:"+typeof(a))
// console.log("Value :"+a)
// a="Hello"
// console.log("Type:"+typeof(a))
// console.log("Value :"+a)


// Constant
  const PI=3.14

 console.log("Type:"+typeof(PI))
 console.log("Value :"+PI)

 PI=67.88

 console.log("Type:"+typeof(PI))
 console.log("Value :"+PI)

 

If you are Happy with DataFlair, do not forget to make us happy with your positive feedback on Google

courses

DataFlair Team

DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.

Leave a Reply

Your email address will not be published. Required fields are marked *