Capture value from nested function in JavaScript
<p>I have the following  code snippet :</p>

<pre><code>function getCheckListTaskWithId(id){

 var tempTask = db.readTransaction(function (tx) {

      tx.executeSql('SELECT * FROM checklisttasks where id=? ', [id], function (tx, results) {
      var len = results.rows.length;
      if(len&gt;0){
        var task=results.rows.item(0);
        var temp= new CheckListTask(task.id,task.crud,task.name,task.status);
        alert(temp);

      }   
    });

  });

}
</code></pre>

<p>the function that I pass to the tx.execute method is a call back function. Now I wan to return temp var present in callback function,  from <code>getCheckListTaskWithId</code> function.</p>

<p>How Do I do this?</p>
