Puas yog ob arrays sib npaug JavaScript?
Puas yog ob arrays sib npaug JavaScript?

Video: Puas yog ob arrays sib npaug JavaScript?

Video: Puas yog ob arrays sib npaug JavaScript?
Video: Data Science with Python! Analyzing File Types from Avro to Stata 2024, Kaum ib hlis
Anonim

Hauv Javascript , sib piv ob arrays peb yuav tsum tau xyuas tias qhov ntev ntawm ob qho tib si arrays yuav tsum zoo ib yam, cov khoom tam sim no nyob rau hauv nws yog tib yam thiab txhua yam khoom nyob rau hauv ib array yog sib npaug mus rau tus counterpart hauv lwm array. Los ntawm kev ua qhov no peb tuaj yeem xaus ob qho tib si arrays yog tib yam los tsis yog. JavaScript muab lub luag haujlwm JSON.

Hais txog qhov no, puas yog ob arrays sib npaug?

Ob arrays raug txiav txim siab sib npaug yog ob leeg arrays muaj tib tus naj npawb ntawm cov ntsiab lus, thiab tag nrho cov khoom sib txuas ntawm cov ntsiab lus hauv lub ob arrays yog sib npaug . Hauv lwm lo lus, ob arrays yog sib npaug yog tias lawv muaj tib lub ntsiab hauv tib qhov kev txiav txim. Arrays chav kawm hauv java muab cov txheej txheem Arrays.

Ib tug kuj yuav nug, ua li cas koj piv arrays? Ib txoj kev yooj yim yog khiav lub voj thiab piv hais ib los ntawm ib tug. Java muab txoj hauv kev ncaj qha Arrays . sib npaug () rau piv ob arrays . Qhov tseeb, muaj cov npe sib npaug () txoj hauv kev Arrays chav kawm rau ntau hom primitive (int, char,..etc) thiab ib qho rau Hom Hom (uas yog lub hauv paus ntawm txhua chav kawm hauv Java).

Ntawm no, peb puas tuaj yeem piv ob yam khoom hauv Javascript?

Muab piv cov khoom yog ib qho yooj yim, siv === los yog Yam khoom .is(). Cov haujlwm no rov qab muaj tseeb yog tias lawv muaj qhov siv tib yam thiab tsis tseeb yog tias lawv ua tsis yog. Ib zaug ntxiv, cia kuv ntxhov siab, nws yog sib piv cov ntaub ntawv rau cov khoom , tsis yog tus nqi ntawm cov khoom . Yog li, los ntawm Piv txwv 3, Yam khoom .is(obj1, obj2); yuav rov cuav.

Kuv yuav piv ob txoj hlua array li cas?

  1. // Program los sib piv ob txoj hlua arrays hauv Java. chav kawm StringUtils.
  2. public static void main(String args) {
  3. String s1 = { "A", "B", "C" }; String s2 = { "X", "Y", "Z" };
  4. yog (Arrays. equals(s1, s2))
  5. Qhov system. tawm. println("Ob lub arrays sib npaug"); lwm tus.
  6. Qhov system. tawm. println("Ob lub arrays tsis sib npaug"); }

Pom zoo: