title: Pushing Unique JQuery Objects to an Array
body: <p>I'm completely new to using Jquery, and I'm trying push unique objects to an array, and if the object is already in the array, it removes them. This is for students to book multiple tutorial classes by clicking on available options, and then submitting the full array with all their selected options.</p>
  
  <p>I've updated my code exactly from what I've written. This code works perfectly if I just use single elements in the array. It cannot evaluate duplicate selected slots if I use objects in the array.</p>
  
  <pre><code>   var bookingSlots = [];
     $('.row').on('click','.slots', function (e) {
      e.preventDefault();
      $(this).toggleClass('selected');
      var slotID = $(this).attr('data-slot-id');
      var studentID = $(this).attr('data-student-id');
      var slot = {slotID: slotID, studentID: studentID};
      var found = jQuery.inArray(slot,bookingSlots);
  
      if(found &lt; 0){
          bookingSlots.push(slot);
      }else{
          bookingSlots.splice(found, 1);
      }
  });
  </code></pre>