简体   繁体   中英

How to use parenthesis in ternary operator in javascript

This code works:

 if(itemNm2!== "total"  )

but

if((itemNm2!== "total" ) || (itemNm2!== "normal(total)"))

doesn't work.

is is because parenthesis is used?

this is full code.

 var rows = resp.Sttsapitbldata[1].row;
    if (rows) {
        var representativeRow;
        for (i = 2; i < Object.keys(rows).length; i++) {
            representativeRow = rows[i];
        itemNm2 = representativeRow.ITM_NM;
        dataV = representativeRow.DTA_VAL;
        if((itemNm2!== "total" ) || (itemNm2!== "normal(total)") ){

            options.data.data.push({DTA_VAL: dataV, ITM_NM: itemNm2});
        }

    }
if((itemNm2!== "total" ) || (itemNm2!== "normal(total)") )

It always return true . I think right code :

if((itemNm2!== "total" ) && (itemNm2!== "normal(total)") )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM