1
朋友你好,鈦手機:合併兩個數組到一個數組問題
我已經在開發鈦的應用程序,我有一個問題是,合併兩個陣列成一個陣列,所以請給我的想法與我的問題。
在此先感謝。
var tableData = ['Restaurants','Coffee','Bars','ATMs','Gas Stations','Hotels','Attractions','Pizza','Post Office'];
var categoryData = [];
var tableData = [];
PlacesTypeCells = function createRow()
{
alert('custom cells'+currentWindow.category);
if(currentWindow.category)
{
alert('add category');
categoryData.push(currentWindow.category);
}
tableData = placeData + categoryData;
Ti.API.log('length:'+tableData);
alert(tableData.length);
}
我想合併placeData和categoryData到資料表陣列,所以請給我知道如何才能做到這一點?
placeData是不是在你的代碼中定義。請糾正它。要合併兩個數組,請使用:javascript concat方法。 – vaibhav 2012-02-23 14:14:08