Cov txheej txheem:

Yuav ua li cas txheeb xyuas qhov sib txawv yog null hauv JavaScript?
Yuav ua li cas txheeb xyuas qhov sib txawv yog null hauv JavaScript?

Video: Yuav ua li cas txheeb xyuas qhov sib txawv yog null hauv JavaScript?

Video: Yuav ua li cas txheeb xyuas qhov sib txawv yog null hauv JavaScript?
Video: Tsis Muaj Peev Xwm Yuav Ua Li Cas 2024, Hlis ntuj nqeg
Anonim

Teb: Siv tus neeg teb xov tooj sib npaug (==)

Whereas, the null yog ib tug tshwj xeeb assignment nqi, uas yuav muab rau a sib txawv ua ib tug sawv cev tsis muaj nqi. Hauv cov lus yooj yooj yim koj tuaj yeem hais a null tus nqi txhais tau tias tsis muaj nqi lossis tsis muaj nqi, thiab tsis tau txhais tau tias a sib txawv uas tau tshaj tawm tab sis tseem tsis tau muab tus nqi.

Ib yam li ntawd, koj ua li cas kuaj rau null?

Part 1 Xyuas Null hauv Java

  1. Siv "=" txhawm rau txheeb xyuas qhov sib txawv. Ib qho "=" yog siv los tshaj tawm qhov sib txawv thiab muab tus nqi rau nws.
  2. Siv “==” txhawm rau txheeb xyuas tus nqi sib txawv. A "= =" yog siv los xyuas tias ob qhov tseem ceeb ntawm ob sab yog sib npaug.
  3. Siv cov lus "yog" los tsim ib qho xwm txheej rau qhov null.

Tsis tas li ntawd, tsis yog null lossis undefined JavaScript? null yog tus nqi muab. Nws txhais tau tias tsis muaj dab tsi. tsis tau txhais feem ntau txhais tau hais tias qhov sib txawv tau tshaj tawm tab sis tsis yog txhais tsis tau. null thiab tsis tau txhais yog tus nqi cuav.

Ntawm no, puas yog tsis muaj tseeb lossis tsis tseeb JavaScript?

Tus nqi null yog a JavaScript literal sawv cev rau tus nqi "tsis muaj" lossis "undefined". null yog ib ntawm JavaScript cov yam tseem ceeb. Nws tsis yog sib npaug rau boolean muaj tseeb los tsis sib npaug rau boolean cuav vim nws tus nqi yog undefined. Tus nqi ntawm null yog ntau inclined rau cuav txawm tsis yog cuav.

Vim li cas null == undefined is true?

Yog vim li cas null yog sib npaug tsis tau txhais yog vim JavaScript hom kab ke thiab kev txheeb xyuas qhov sib npaug. Nyob rau hauv ib tug conditional, koj muaj muaj tseeb thiab cuav, tau kawg, tab sis qee yam khoom raug yuam kom muaj tseeb thiab tsis tseeb boolean qhov tseem ceeb. Yog vim li cas null yog sib npaug tsis tau txhais yog vim JavaScript hom kab ke thiab kev txheeb xyuas qhov sib npaug.

Pom zoo: