title: How to delete data from the js array from this data structure?
body: <p>I need time to compare online and offline time. If is more off-line time than online time - this time I need to delete. When the user has no time line - I need to delete this user.</p>
  
  <p>I have this problem: When going through times and smažuj is: there remains a value of "undefined" - [undefined, undefined] and then this condition can not be satisfied -</p>
  
  <pre><code>if (user.connectionTimes.length === 0) {
          delete users[id];
      }
  </code></pre>
  
  <p>How do I solve this problem?</p>
  
  <p>I use the following code:</p>
  
  <pre><code>     var users = [];
  
          users[0] = {
              userId: 1,
              connectionTimes:
                  [
                      {onlineTime:30, offlineTime:70},
                      {onlineTime:50, offlineTime:75}
                  ]
          };
  
          users[1] = {
              userId: 2,
              connectionTimes:
                  [
                      {onlineTime:80, offlineTime:70}
                  ]
          };
  
          users[2] = {
              userId: 3,
              connectionTimes: []
          };
  
          for( var i=0; i&lt;users.length; i++) {
          for( var j=0; j&lt;users[i].connectionTimes.length; j++) {
              if( users[i].connectionTimes[j].onlineTime &lt; users[i].connectionTimes[j].offlineTime) {
       delete users[i].connectionTimes[j];           
      //EDIT - this work - users[i].connectionTimes.splice(j, 1);
      //j--;
              }
          }
          if( users[i].connectionTimes.length == 0) {
  delete users[i];
  
              //EDIT - this work - users.splice(i, 1);
              //i--;
          }
      }
  
          console.log(users);
  </code></pre>