Arguments to JavaScript Anonymous Function

前端 未结 5 865
悲&欢浪女
悲&欢浪女 2021-02-13 11:47
for (var i = 0; i < somearray.length; i++)
{
    myclass.foo({\'arg1\':somearray[i][0]}, function()
    {
        console.log(somearray[i][0]);
    });
}
5条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-13 12:01

    for (var i = 0; i < somearray.length; i++)
    
    {
        myclass.foo({'arg1':somearray[i][0]}, function(somearray)
        {
            console.log(somearray[i][0]);
        });
    }
    

    And then in method foo call anonymous function with param.

提交回复
热议问题