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

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 Overflow. Here’s a small snippet of code I’m working on where I need this kind of functionality:

var tutorTimes = {};

$(checked).each(function(idx){
  id = $(this).attr('class');

  if(id in tutorTimes){}
  else{
    //Rest of my logic will go here
  }
});

As you can see, I’d be putting everything into the else statement. It seems wrong to me to set up an ifelse statement just to use the else portion.

6 Answers
6

Leave a Comment