Javascript参数为数组?

Tro*_*roy 0 javascript arrays arguments function

所以我有一个关于这个事件的按钮:

onmousedown="hideElements('\x22cartview\x22,\x22other\x22')"
Run Code Online (Sandbox Code Playgroud)

然后这个函数hideElements:

function hideElements(what)
  {
  var whichElements=[what];
  alert(whichElements[0]);
  }
Run Code Online (Sandbox Code Playgroud)

我希望它提醒"cartview",但它提醒

"cartview", "其他"

我知道arguments对象,但在这种情况下我不知道如何使用它来访问逗号分隔的单个字符串.可能有一个简单的解决方案,但我对此有点新意.谢谢!

Dar*_*rov 5

onmousedown="hideElements([ 'cartview', 'other' ])"
Run Code Online (Sandbox Code Playgroud)

然后:

function hideElements(what) {
    alert(what[0]);
}
Run Code Online (Sandbox Code Playgroud)