简体   繁体   中英

How to call a method within a method from another method?

In a javascript file I have this:

Work.expenses= function (params)
{
    function deleteExpenses() 
    {
      //here I want to call the loadExpensesList method
    }
}

Work.expensesList= function (params)  
{
    function loadExpensesList() 
    {
     //this is the method I want to call
    }
}

How do I call the loadExpensesList method in the deleteExpenses method? Thank you!

Work.expenses= function (params)
{
    function deleteExpenses() 
    {
      Work.expensesList('something')();
    }
}

Work.expensesList= function (params)  
{
    function loadExpensesList() 
    {

    }
    return loadExpensesList;
}

You can try like this. But can be better by understanding the requirement.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM