var item = ['t', 'd', 's'], items = ''; for (i = 0; i < 4; i++) if (item[i] !== undefined) items += item[i]; alert(items);