Dab tsi yog cov lus hloov pauv hauv JavaScript?
Dab tsi yog cov lus hloov pauv hauv JavaScript?

Video: Dab tsi yog cov lus hloov pauv hauv JavaScript?

Video: Dab tsi yog cov lus hloov pauv hauv JavaScript?
Video: yog hmoov dab tsi tub huas xyooj 2024, Hlis ntuj nqeg
Anonim

Cov hloov nqe lus executes ib block ntawm code nyob ntawm qhov sib txawv. Cov hloov nqe lus yog ib feem ntawm JavaScript cov "Conditional" Nqe lus , uas yog siv los ua qhov sib txawv raws li cov xwm txheej sib txawv. Cov hloov nqe lus feem ntau siv ua ke nrog kev so lossis ib lo lus tseem ceeb (los yog ob qho tib si).

Raws li, JavaScript puas muaj cov lus hloov pauv?

Ntxiv rau ifelse, JavaScript muaj ib tug feature hu ua a hloov nqe lus . hloov yog hom conditional nqe lus uas yuav ntsuas ib qho kev qhia tawm tsam ntau qhov xwm txheej thiab ua tiav ib lossis ntau qhov thaiv ntawm cov cai raws li qhov sib txuam.

Ib sab saum toj no, koj sau daim ntawv hloov pauv li cas? Cov lus "hloov ".

  1. Tus nqi ntawm x yog kuaj xyuas qhov sib npaug nruj rau tus nqi los ntawm thawj rooj plaub (uas yog, tus nqi 1) ces mus rau qhov thib ob (tus nqi 2) thiab lwm yam.
  2. Yog tias pom qhov sib npaug, hloov pauv pib ua cov cai pib los ntawm cov ntaub ntawv sib raug, kom txog rau thaum qhov ze tshaj plaws (lossis txog thaum kawg ntawm kev hloov).

Raws li txoj cai, daim ntawv qhia hloov pauv ua li cas?

Hauv computer programming lus, a hloov nqe lus yog ib hom kev xaiv tswj mechanism siv los tso cai rau tus nqi ntawm qhov sib txawv lossis kev qhia los hloov cov kev tswj hwm kev khiav haujlwm ntawm kev tshawb nrhiav thiab daim ntawv qhia.

Cov lus piv txwv hloov pauv yog dab tsi?

A hloov nqe lus kuaj tus nqi ntawm qhov sib txawv thiab sib piv nrog ntau qhov xwm txheej. Ib zaug lub cas match yog pom, ib qho thaiv ntawm nqe lus txuam nrog qhov tshwj xeeb cas raug tua. Txhua cas hauv block a hloov muaj lub npe sib txawv / tus lej uas raug xa mus ua tus cim.

Pom zoo: