Tsuas siv null yog tias koj xav qhia meej txog tus nqi ntawm qhov sib txawv li "tsis muaj nqi". Raws li @com2gz hais tias: null yog siv los txhais ib yam dab tsi programmatically khoob. undefined yog txhais tau hais tias qhov kev siv tsis muaj nyob. Tus nqi tsis muaj nuj nqis muaj qhov txhais tau hais tias "tsis muaj dab tsi ".
Thaum twg koj yuav tsum siv lub ntsiab tsis muaj?
Thaum qhov sib txawv lossis cov cuab yeej ntawm ib qho khoom tsis muaj tus nqi nws yog undefined, thiab rau tus nqi yuav tsis muaj nuj nqis koj yuav tsum muab nws tus nqi null. Raws li qhov sib txawv twb tsis muaj nuj nqis nws yog kiag li tsis muaj ntsiab lus nyob rau hauv tshaj tawm hais tias dua nrog rau lwm yam uas thaum kawg muaj lub ntsiab lus.
Puas yog kev xyaum phem rov qab tsis tau txhais?
A muaj nuj nqi rov qab tsis tau txhais yog tias tus nqi tsis rov qab. Nco tseg: Thaum koj tuaj yeem siv tsis tau txhais ua tus cim (lub npe hloov pauv) hauv txhua qhov uas tsis yog lub ntiaj teb cov peev txheej (vim tias tsis tau txhais tsis yog ib lo lus tshwj tseg), ua li ntawd yog lub tswv yim phem heev uas yuav ua rau koj cov cai nyuaj rau kev tswj thiab kho qhov teeb meem.
Is null==undefined?
null yog tus nqi muab. Txhais tau tias nothing. undefined txhais tau hais tias qhov sib txawv tau tshaj tawm tab sis tseem tsis tau txhais.
Vim li cas null==undefined is true?
Tus==tus neeg teb xov tooj sib piv tsis txheeb xyuas hom. null thiab undefined ob qho tib si rov qab tsis raug. Tias yog vim li cas koj txoj cai yog tiag tiag tshuaj xyuas yog qhov cuav yog sib npaug. Txawm li cas los lawv hom tsis sib npaug.