variable

Estimated reading time: 1 minute

variable is a container where storing data .

naming

Limiation

  • only letters,digits,symbols,$,_
  • first character must not be a digit.
  • case sensitive
  • camel case (optionalMatter)

let

  • let is local variable
  • don’t access outside of block
  • don’t duplicate accept same block
let name = 'code4mk'
{
  let name = 'kamal';
  console.log(name);
}
console.log(name);

var

  • var
  • access any where
  • last value is current value
var name = 'code4mk'
{
  var name = 'kamal';
  console.log(name);
}
console.log(name);

const

  • const always fixed
  • no change allow
const price = 51;
// const price = 55 // error
console.log(price);
js