mercredi 14 mai 2014

How does scoping work in javascript


Vote count:

1




I am relatively new to javascript and working on nodejs. I have a situation if reduced woulf boil down to following code. Can I return directly in the callback with out creating another variable(temp) like I did in the below code.



var a = function(param,callback) {
callback(param);
};

var c = function() {
val temp = null;
a(5, function(a){
temp = 2*a;
});

return temp;
}


asked 1 min ago

raju

468





Aucun commentaire:

Enregistrer un commentaire