Is there a “not in” operator in JavaScript for checking object properties?

后端 未结 4 1491
有刺的猬
有刺的猬 2020-12-07 19:35

Is there any sort of \"not in\" operator in JavaScript to check if a property does not exist in an object? I couldn’t find anything about this around Google or Stack Overflo

4条回答
  •  北海茫月
    2020-12-07 20:12

    It seems wrong to me to set up an if/else statement just to use the else portion...

    Just negate your condition, and you'll get the else logic inside the if:

    if (!(id in tutorTimes)) { ... }
    

提交回复
热议问题