← 返回首页
if (a string with zero)
EN

We want to make this open-source project available for people all around the world.

Help to translate the content of this tutorial to your language!

    Search
    Search
    Light themeDark theme
    عربيDanskEnglishEspañolفارسیFrançaisIndonesiaItaliano日本語한국어РусскийTürkçeУкраїнськаOʻzbek简体中文
    back to the lesson

    if (a string with zero)

    importance: 5

    Will alert be shown?

    if ("0") { alert( 'Hello' ); }
    solution

    Yes, it will.

    Any string except an empty one (and "0" is not empty) becomes true in the logical context.

    We can run and check:

    if ("0") { alert( 'Hello' ); }