I am working on a code snippet that is something like nested functiones inside again and again in JavaScript and when I am calling the most outer function then I want the value returning from the inner function as below.
function BooleanFunc(par) {
function(){
function(){
if(par === 0){
return true;
}
else {
return false;
}
};
};
};
if(BooleanFunc(0)){
alert("Returning True...");
}
else {
alert("Returning False...");
}
To work on easy, here is the FIDDLE of this code. Me using the Pure JavaScript. There are many solution available but those are for that nested functions that have some names but in my case, inner function have no name and I cant change the functions. So How to return the Value from nested functions...???
UPDATED:
I am working on a code that is using the WebSQL. From the below code, I am searching my player in the database and i its found there then it will return TRUE or else it will return FALSE. But its not working...
/* SEARCH
----------------------------------------------- */
function searchPlayer(player) {
// Check To Ensure That mydb Object Has Been Created
if (mydb) {
// Select The Matched Query
mydb.transaction(function (t) {
t.executeSql("SELECT COUNT(*) AS c FROM myTable WHERE playername = ?", [player],
function(t,results){
if(results.rows[0].c > 0){
return true;
}
else {
return false;
}
},
function(t,error){
alert("Error: " + error.message);
}
);
});
}
else {
alert("Database Not Found, Your Browser Does Not Support WebSQL...!!!");
}
}
SOLUTION:
The nested function is taking time to load and reply so I just gave some time difference between both sets of codes so after this second set of code is working fine on reply of first set of code.