Why can't I call an array method on a function's arguments?

前端 未结 8 1318
鱼传尺愫
鱼传尺愫 2020-12-03 05:07

I have a function that can accept any number of arguments...

const getSearchFields = () => {        
    const joined = arguments.join(\'/\'); 
};
         


        
8条回答
  •  醉话见心
    2020-12-03 05:44

    If you are using jQuery 1.2+, you can use $.makeArray():

    Convert an array-like object into a true JavaScript array.

    From the example in the question, just use this line

    var args = $.makeArray(arguments);
    

提交回复
热议问题