我希望能夠通過使用字符串來引用數組,因爲這樣的:如何使用jQuery中的另一個變量通過名稱引用變量?
var arrayName = "people";
var people = [
'image47.jpeg',
'image48.jpeg',
'image49.jpeg',
'image50.jpeg',
'image52.jpeg',
'image53.jpeg',
'image54.jpeg',
'image55.jpeg',
]
function myFunc (arrayName)
{
//arrayName is actually just a string that evaluates to "people", which then in turn would reference the var people, which is passed in.
}
如何做到這一點有什麼想法?對不起,如果我錯過了明顯的東西。
'變種arrayName中的[] =人[]',這需要來_after_ var people []。 – Ohgodwhy 2012-03-20 02:09:01
看到這個http://stackoverflow.com/questions/952457/javascript-using-variable-as-array-name – 2012-03-20 02:13:30