Variables

Variables

Wa maxey variable ? variable wa macluumaad keydiye, macluumaad kaasi wuxu noqon karaa qoraal/xarfo, tiro/numbers ama sawir.

Markad qeexeysid javaScript variable waxa jiro sharci la raacayo, waxaana la ogol yahay iney ku jiran xarfo,lambaro, dollar sign 💲, iyo under score _

 

Tusaale

Hadii sidan aad sameysid kuu shaqeen meyso.

				
					const 2 = "ali"; //error
let 2_name = "ahmed"; //error
var 2name = "fatma"; //error
const 2$ = "zaky"; //error
				
			

 

Sidaan ayaa sax ah 

				
					const name2 = "ali"; 
let _name = "ahmed";
var name$ = "fatma"; 
const $2 = "zaky"; 
				
			

Sidokale waxaa wanaagsan variables kaaga in magac la fahmi karo aad u bixiso ama ogu yaraan uuka turjumayo macluumaadka ku jiro.

 

Good variable name

				
					const name = "Ahmed";
let age = 24;
				
			

 

Bad variable name

				
					const a = "Ahmed";
let x = 24;
				
			

 

 

JavaScript variable decleration rule 

Markad javaScript variable declare/qeexeysid waxa jiro waxyaabo aana haboonen inad sameyso sabab jirto owgeed. Tusaale inaad xarafka ogu horeeyo ee variable kaaga aad ka dhigto capital-letter/xaraf-weyn wax wanaagsan ma ahan, sababto ah javaScript waxa xarafka ogu horeyo far-waweyn laga dhigaa function constructor iyo classes, function constructor iyo classes gadaal ayan ka baran doona insha Allah.

Next Lesson >

Share