2 functions calling each others, how to declare them ?
Hello,
I have a pretty simple problem :
I have 2 functions :
function displayItems(itemList){
--------some code here------
feedTableView.addEventListener('scrollEnd',function(e)
{
loadRSSFeed(url)
});
---------some other code here-------
}
function loadRSSFeed(url){
--------some code here------
// Now add the items to a tableView
displayItems(itemList);
---------some other code here-------
}
and of course I get the warning : loadRSSFeed was used before it was defined..
So is there a way to just declare the functions first before writing their content code ?
Regards
Armindo
2 Answers
-
Accepted Answer
>So is there a way to just declare the functions first before writing their content code ?
You can just declare one (or both) using var to eliminate the warning:
var loadRSSFeed; function displayItems() { ... }; function loadRSSFeed() { ... };
It doesn't matter if loadRSSFeed ends up being a function, object, or data type.
-
Great ! thanks Doug.