Why doesn't .join() work with function arguments?

后端 未结 8 1602
遇见更好的自我
遇见更好的自我 2021-02-01 11:59

Why does this work (returns \"one, two, three\"):

var words = [\'one\', \'two\', \'three\'];
$(\"#main\").append(\'

\' + words.join(\", \") + \'

8条回答
  •  轮回少年
    2021-02-01 12:21

    arguments is not a jQuery object, just a regular JavaScript object. Extend it before you try to call .join(). I think you would write:

    return 'the list:' + $(arguments)[0];
    

    (I'm not too familiar with jQuery, only Prototype, so I hope this is not completely bogus.)

    Edit: It's wrong! But in his response, Doug Neiner describes what I'm trying to accomplish.

提交回复
热议问题