variable waxa lagukaydiya wax yaabaha aad isticmalayso hadhow code kaaga. let laftirkeeda waxa loogu talagalay in wax lagu asign gareeyo wana labadalikara hadi loobahdo hashow. teeda kale let laftirkeed ayaaba ah variable logu talagalay in wax lagu kaydiyo.
wll farqiga udhaxeeyo waxaa waaye variable waa weel ki aad kushuban laheed datadaada halka let ay thy keyword, keyword kana waxaa waaye erayo luqada ay laydahy(waa araybixinta luqada ay lay dahy(terminology)) kaasoo gooni uha tusaale markii aad rabto in kheexdo varaible javascript waa in aad kohormarisaa keword ka layiraahdo let ama var ama const tusaale
let name =’peyaza’;
console.log(‘magacaygu waa ‘ + name)
result :magacaygu waa peyaza
let
1. waxa luuqada js lagu soo daray 2015 or ES6
2.dib loo ma qeexi karo
3. laakiin qiima ha waa ka bali kartaa
var
- waxa la cisticmaali jiray wixii ka horeeyay 2015 (old) or ES6
- dib ayaa u qeexi karta taas oo aan fiicnayn
- dib ayaa qiimaha uga badali kartaa
// var
var score1 = 2;
var score1 =3 ;
console.log(score1)// let
let score2 = 2;
//let score2 =3 ;
//wuxu kuu soo saraarayaa errorkan=> Identifier ‘score2’ has already been declared
//
console.log(score2)//lk sidani waa sax let markaa value ama qiimaha badalayso
let score3 = 2;
score3 =3 ;
console.log(score3)
REC0MMENDATION ==> ka fagoow var ilaa aad ubaahato isticmaal marwal ba let
let is a new way for declaring variables while var is an old version of variable declaration in javascript.