Equality Operators (== vs ===)? Waxaa jiro labo is-barbar dhig oo la isticmaalo markii aad javaScript is-barbar dhig sameeneysid waana == (double) equal operator iyo === (triple) equal operator. Equality Operators (== vs ===), labadu waxa ey so saaran boolean result sida true ama false.
Double (==) equality, waxa ey hubisaa okaliya hadii labada shey ee la is-barbar dhigayo ey isku qiimo yihiin, yacni hadii wax iskumid ah ey ku jiraan.
console.log("24" == 24); // true
“24” data-type-keeda wa Strings, 24 data-type keedu wa Number.
tusaalahan kore waxaan is-barbar dhig ku sameeney hadii “24” qoraal ah ey lamid tahay 24 tiro ah, natiijada so baxdeyne waa true/haa, waayo double (==) equality waxey hubineysa value/qiimaha ee ma hubineyso type ka.
Double (==) equality sidokale waxa lo yaqaanaa loose-equality.
Triple (===) equality, waxey ka duwan tahay double equality waayo waxey hubineysa hadii labada shey ee la is-barbar dhigayo ey iskaga mid yihiin qiimaha/value_ga iyo nooca/type.
console.log("24" === 24); // false
Triple(===) equality, waxey fiirineysa “24” qoraal ah iney lamid tahay 24 tiro ah natiijaduna waa false/maya, waayo wa isku qiimo lakin wa kala nooc xaga data-type ka.
Double(==) equality markad isticmaaleysid waxey hoos ka sameeneysa type-coercion labada value mid kamid ah ayey data-type kiisa badaleysa si midka kale ey ula ekeysiiso ama ogala mid dhigto.
Tripe (===) equality wax type-coercion ah ma sameyso si toos ah ayey u fiirineysa hadii ey isku data-type yihiin iyo isku qiimo, kadib ayey natiijada kuso saareysa.
Midkee wanaagsan inaad isticmaasho? waxa wanaagsan Tripe(===) equality inaad isticmaasho waayo iyada ka hubin/checking fican doube(==) equality, madaama double equality ey sameeyso type-coercion
sidokale intii javaScript ey ku sameen laheed type-coercion waxa fican inad adiga badasho type_ka.
Aqriste waxaan rajeenaya inaad wax badan ka faa’iidey qormadaan.