Qhov txawv ntawm rau hauv thiab rau ntawm yog dab tsi?
Qhov txawv ntawm rau hauv thiab rau ntawm yog dab tsi?

Video: Qhov txawv ntawm rau hauv thiab rau ntawm yog dab tsi?

Video: Qhov txawv ntawm rau hauv thiab rau ntawm yog dab tsi?
Video: Qhov ceev faj ntawm lub taub dag nov yog dab tsi 16 Jan 2019 2024, Kaum ib hlis
Anonim

Qhov txawv rau..thiab rau..ntawm:

Lub xwb txawv yog tshaj qhov lawv iterate: rau..in iterates tshaj tag nrho enumerable cov cuab yeej yuam sij ntawm ib yam khoom. rau.. ntawm iterates tshaj qhov tseem ceeb ntawm ib yam khoom iteable. Piv txwv ntawm cov khoom siv tau yog arrays, hlua, thiab NodeLists.

Hais txog qhov no, qhov txawv ntawm rau hauv thiab rau OF hauv JavaScript?

rau hauv yog siv los voj los ntawm cov khoom ntawm ib yam khoom. Nws tuaj yeem yog txhua yam khoom. rau hauv tso cai rau koj nkag mus rau cov yuam sij ntawm cov khoom tab sis tsis muab kev siv rau qhov tseem ceeb. Hauv JavaScript Cov khoom ntiag tug lawv tus kheej muaj cov khoom siv sab hauv.

uas yog qhov zoo dua rau lossis rauEach hauv JavaScript? rauTxhua yooj yim nyeem hauv a rauTxhua txoj kev, peb dhau txhua hom zaub mov nyob rau hauv uas iteration rau hauv callback. A rau lub voj xav kom koj nkag mus rau array siv ib ntus i kuj sib txawv. Thaum qhov no yuav tsis zoo li ntxhov heev thaum pib, nws tuaj yeem tau txais ntau cluttered thaum koj pib ntxiv ntau code.

Tsis tas li ntawd, qhov sib txawv ntawm rau thiab rauEach yog dab tsi?

Qhov loj tshaj sib txawv yog a ua ntej voj txheej txheem ib qho piv txwv ntawm txhua lub ntsiab hauv a sau nyob rau hauv lem, thaum lub voj voog tuaj yeem ua haujlwm nrog cov ntaub ntawv thiab tsis txwv rau cov khoom sau ib leeg. Qhov no txhais tau hais tias ib lub voj voog tuaj yeem hloov kho cov khoom sau - uas tsis raug cai thiab yuav ua rau muaj qhov yuam kev nyob rau hauv ib tug foreach lub voj.

Dab tsi yog qhov txawv ntawm rau thiab forEach hauv Java?

Lub rau voj yog qhov zoo tshaj plaws rau iterating tshaj lub npe-tus nqi khub, thiab cov rauTxhua yog lub voj zoo tshaj plaws rau iterating tshaj qhov tseem ceeb, piv txwv li arrays lossis khoom. Lub voj voog yog qhov zoo tshaj plaws rau cov npe-tus nqi khub. Lub voj voog tuaj yeem siv los tshawb txog cov khoom ua tau thiab txoj hauv kev ntawm ib qho khoom. Cov rauTxhua Loop yog qhov zoo tshaj plaws rau iterating qhov tseem ceeb.

Pom zoo: