var companyArr = []; var index = $.inArray("str", companyArr); if (index < 0) { companyArr.push("str"); }