Cov txheej txheem:

Koj tuaj yeem tshawb xyuas seb qhov khoom puas yog khoob lossis tsis nyob hauv JavaScript?
Koj tuaj yeem tshawb xyuas seb qhov khoom puas yog khoob lossis tsis nyob hauv JavaScript?

Video: Koj tuaj yeem tshawb xyuas seb qhov khoom puas yog khoob lossis tsis nyob hauv JavaScript?

Video: Koj tuaj yeem tshawb xyuas seb qhov khoom puas yog khoob lossis tsis nyob hauv JavaScript?
Video: Leng Yang - Yog Vim Dab Tsi (Official Full Song | Nkauj Tawm Tshiab) 2020/05/24 2024, Kaum ib hlis
Anonim

Txoj hauv kev zoo tshaj plaws los xyuas seb qhov khoom puas yog los ntawm kev siv autility muaj nuj nqi zoo li hauv qab no

  1. function isEmpty(obj) { rau (var key in obj) { yog (obj.
  2. var myObj = {}; // Empty Object yog (isEmpty(myObj)) { // Cov khoom yog khoob (Yuav rov qab muaj tseeb hauv qhov piv txwv no) } else {// Yam khoom TSIS yog khoob }
  3. Yam khoom .

Hauv qhov no, puas yog qhov khoom khoob qhov tseeb?

Ib (1) yog qhov tseeb , Xoom (0) yog cuav. Ib khoom ntawm txhua yam (nrog rau kev ua haujlwm, arrays, RegExp khoom , etc.) yog ib txwm qhov tseeb . undefined, null, NaN, 0, "" ( khoob txoj hlua), thiab cuav, tau kawg.

Ib yam li ntawd, puas yog Empty object jQuery? jQuery .isEmptyObject( khoom ) Rov qab: Boolean Description: Kos saib yog tias muaj khoom yog khoob (tsis muaj enumerableproperties).

Ntawm no, yog cov hlua khoob khoob hauv Javascript?

Tab sis, ntawm qhov thib ob, txhua qhov tseeb-ish tus nqi yuav nkag mus yog: cuav, 0, null , undefined thiab cov hlua khoob , yuav tsis. Ob leeg null thiab ib txoj hlua khoob yog falsy values nyob rau hauv JS . Yog li ntawd, tsis muaj cov null (los yog tej yam txawv txawv xws li cov ntaub ntawv = "0") tau txais hauv txoj kev.

Puas yog khoob hauv Java?

Java Txoj hlua isEmpty() method withexample Java String isEmpty() method check seb aString yog khoob los tsis. Txoj kev no rov qab muaj tseeb yog tias txoj hlua muab yog khoob , lwm yam nws rov qab cuav. Hauv lwm lo lus koj tuaj yeem hais tias txoj kev no rov qab muaj tseeb yog tias qhov ntev ntawm txoj hlua yog 0.

Pom zoo: