Koj puas yuav tsum tshaj tawm cov hloov pauv hauv JavaScript?
Koj puas yuav tsum tshaj tawm cov hloov pauv hauv JavaScript?

Video: Koj puas yuav tsum tshaj tawm cov hloov pauv hauv JavaScript?

Video: Koj puas yuav tsum tshaj tawm cov hloov pauv hauv JavaScript?
Video: Tub Vanh Lauj {Nkauj Tawn Tshiab} Koj Puas Yuav Hlub Kuv 9/6/2021 2024, Kaum ib hlis
Anonim

Ua ntej koj siv a sib txawv hauv a JavaScript qhov program, koj yuav tsum tshaj tawm nws. Hloov pauv yog tshaj tawm nrog rau var lo lus tseem ceeb raws li nram no. Khaws tus nqi hauv a sib txawv hu ua sib txawv pib. Koj ua tau ua variable pib thaum lub sij hawm ntawm sib txawv creation los yog tom qab taw tes nyob rau hauv lub sij hawm thaum koj xav tau uas sib txawv.

Hauv qhov no, koj tshaj tawm qhov sib txawv hauv JavaScript li cas?

JavaScript siv cov lus tseem ceeb tshwj xeeb var rau tshaj tawm ib variable . A sib txawv yuav tsum muaj lub npe tshwj xeeb. Koj ua tau muab tus nqi rau a sib txawv siv sib npaug rau (=) tus neeg teb xov tooj thaum koj tshaj tawm nws los yog ua ntej siv nws. Hauv qhov piv txwv saum toj no, peb tau tshaj tawm peb sib txawv siv var lo lus tseem ceeb: ib, ob thiab peb.

Ib tug kuj yuav nug, ua li cas koj tshaj tawm txawv txawv? Yuav tshaj tawm qhov hloov pauv li cas:

  1. Xaiv "hom" koj xav tau.
  2. Txiav txim siab lub npe rau qhov sib txawv.
  3. Siv hom ntawv hauv qab no rau daim ntawv tshaj tawm:
  4. Koj tuaj yeem tshaj tawm ntau dua ib qho kev sib txawv ntawm tib hom los ntawm kev sib cais cov npe sib txawv nrog commas.

Kuj paub, ua li cas koj tshaj tawm ntau qhov sib txawv hauv JavaScript?

Ntau qhov sib txawv hauv JavaScript kuj tuaj yeem raug chained, thaum sib cais los ntawm ib qho comma. Tom qab thawj tshaj tawm ntawm a sib txawv nyob rau hauv lub ntiaj teb no Scope, tom qab tshaj tawm ntawm a sib txawv siv lub npe var ua tau. Tam sim no peb yuav tau saib lwm tus sib txawv hom, cia thiab const.

Lo lus tseem ceeb twg yuav tsum kos siv rau kev tshaj tawm sib txawv hauv JavaScript?

SIB NTAUS NTAU VAR THIAB cia KEYWORD Thaum twg Javascript tau tsim, tib txoj kev tshaj tawm a sib txawv yog los ntawm kev siv lub var lus . Hloov pauv tshaj tawm nrog var yog pib nrog undefined yog hais tias peb tsis muab nws tej nqi.

Pom zoo: