I have some borrowed code I’m trying to tweak for my needs. Ref. below code:
// Object that will contain all of the MRNs we want to keep
var assgnAuthToKeep = {};
for each(pid3 in PIDsegment['PID.3']) {
if (pid3['PID.3.4'].toString() in assgnAuthToKeep) {
delete PIDsegment[pid3.childIndex];
}
}
How can I check for the value NOT IN the object in the if statement?
!in doesn’t work nor does not in
3
Answers
Like how Rogue mentioned you can invert the boolean expression. Here is your block of code using that method instead:
The !in operator is a valid way to check if a value is not in an object. However, the syntax in your code is incorrect. You need to use the ! operator before the in operator, not after.
I have a few questions:
PIDsegment
look like?assgnAuthToKeep
aSet
, aMap
, or anObject
?childIndex
is.From what I can infer, it looks like you want to use
for..of
instead offor..in
, if you want to access a key on a value.