predQuery[preId]=='undefined'
You're testing against the string 'undefined'
; you've confused this test with the typeof
test which would return a string. You probably mean to be testing against the special value undefined
:
predQuery[preId]===undefined
Note the strict-equality operator to avoid the generally-unwanted match null==undefined
.
However there are two ways you can get an undefined
value: either preId
isn't a member of predQuery
, or it is a member but has a value set to the special undefined
value. Often, you only want to check whether it's present or not; in that case the in
operator is more appropriate:
!(preId in predQuery)