title: Javascript push object into array not working
body: <p>im using node mirc to retrieve data from mysql</p>
  
  <p><a href="https://i.stack.imgur.com/2R48w.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2R48w.png" alt="enter image description here"></a></p>
  
  <p>then i want convert data to array, using code below :</p>
  
  <pre><code>function getQuestion (arr{
      var obj = {};
  
      connection.connect();
      connection.query("SELECT * FROM quiz", function (err, rows, fields) {
          if (err) throw err;
  
          for (var i = 0; i &lt; rows.length; i++) {
              var row = rows[i];
              obj = {"id":row.id, "question":row.question, "answers":row.answers.split(", ")};
              f100.push(obj);
          };
      });
      connection.end();
  }
  f100 = [];
  getQuestion();
  console.log(f100);
  </code></pre>
  
  <p>but, its only print <code>[]</code></p>