jeudi 1 septembre 2016

Is there any clear way to do a list of AND NOT conditions in javascript?

now I have a json object with following sample:

{
    "a1": "xxx",
    "a2": "xxx",
    "a3": "xxx",
    "b": "xxx",
    "c": "xxx",
    "d": "xxx",
    "e": "xxx",
    "f": "xxx"
}

which a1,a2,a3 do not always have the same key
(it may change key name as b1,b2,b3 or any other key name etc.)


Therefore, when I want to get these key's value, I will add the following condition inside a for-loop:

if (key!="b" && key!="c" && key!="d" && key!="e" && key!="f") {}

but I want to have a clear way to do this condition.
Is there any better solution for this?

Aucun commentaire:

Enregistrer un commentaire