Operators: Arithmetic, Comparison, Logical

JavaScript waa luqad loo adeegsado dhinaca macaamilka bogagga internet-ka (client-side) si loo abuuro hawlgallo isdhexgal ah iyo waxqabadyo kala duwan. Waxa ka mid ah waxyaabaha aasaasiga ah ee ku jira JavaScript waa Operators, kuwaas oo loo isticmaalo in lagu fuliyo xisaabinta, is-barbardhigga, iyo go'aan gaarista. Casharkan, waxaan si faahfaahsan u baran doonaa saddexda nooc ee ugu muhiimsan: Arithmetic Operators, Comparison Operators, iyo Logical Operators.

Operators: Arithmetic, Comparison, Logical
 Operators: Arithmetic, Comparison, Logical


1. Arithmetic Operators (Hawlgalayaasha Xisaabta)

Arithmetic operators waxay kuu ogolaanayaan inaad sameyso hawlgallo xisaabeed sida ku daris, ka jaris, isku dhufasho, iyo qaybinta. Qaar ka mid ah arithmetic operators ee muhiimka ah waxaa ka mid ah:

  • + : Wadarta (ku daris)
  • - : Farqiga (ka jaris)
  • * : Isku dhufasho
  • / : Qaybinta
  • % : Hadhaaga (modulus)
  • ++ : Hal kor u kordhin (increment)
  • -- : Hal hoos u dhim (decrement)

Tusaale:

javascript

let a = 10; let b = 5; console.log(a + b); // 15 console.log(a - b); // 5 console.log(a * b); // 50 console.log(a / b); // 2 console.log(a % b); // 0

2. Comparison Operators (Hawlgalayaasha Is-barbardhigga)

Comparison operators waxaa loo isticmaalaa in lagu isbarbardhigo laba qiime oo kala duwan. Waxay soo celiyaan (return) natiijo nooca true ama false iyadoo ku xiran xaaladda. Qaar ka mid ah comparison operators ee muhiimka ah waxaa ka mid ah:

  • == : Isu ekaanshaha qiimaha (equality)
  • === : Isu ekaanshaha qiimaha iyo nooca (strict equality)
  • != : Aan isku ekaansho ahayn (inequality)
  • !== : Aan isku ekaansho iyo nooc ahayn (strict inequality)
  • > : Ka weyn
  • < : Ka yar
  • >= : Ka weyn ama u dhigma
  • <= : Ka yar ama u dhigma

Tusaale:

javascript

let x = 8; let y = 12; console.log(x > y); // false console.log(x < y); // true console.log(x == 8); // true console.log(y !== 10); // true

3. Logical Operators (Hawlgalayaasha Mantaqiyeed)

Logical operators waxaa loo isticmaalaa in lagu sameeyo hawlgallo mantaqi ah (logical operations) sida iyo (AND), ama (OR), iyo inkir (NOT). Waxaa badanaa loo isticmaalaa qaababka go'aan gaarista (decision-making).

  • && : AND (iyo) – run marka dhammaan xaaladaha ay sax yihiin
  • || : OR (ama) – run marka mid ama dhammaan xaaladaha ay sax yihiin
  • ! : NOT (inkir) – beddelka xaaladda (true to false ama false to true)

Tusaale:

javascript

let isAdult = true; let hasPermission = false; console.log(isAdult && hasPermission); // false console.log(isAdult || hasPermission); // true console.log(!isAdult); // false

Gunaanad:

Operators waa qayb muhiim ah oo ka mid ah JavaScript oo kuu ogolaanaysa inaad sameyso hawlgallo kala duwan sida xisaabinta, is-barbardhigga qiimayaasha, iyo samaynta go'aanno mantaqi ah. Fahamka saxda ah ee Arithmetic, Comparison, iyo Logical Operators waxay kaa caawinayaan inaad abuurto barnaamijyo waxtar leh oo xalliya dhibaatooyin kala duwan.

Isku day inaad tijaabiso operators-kan si aad u aragto sida ay u shaqeeyaan iyo sida aad uga faa'iidaysan karto barnaamijyadaada!

Previous Post Next Post