javascript array diff function

function subtract_array(a_array, b_array) { var my_result, tmp_f, i, ii; my_result = new Array(); for (i = 0; i < a_array.length; i++) { tmp_f = true; for (ii = 0; ii < b_array.length; ii++) { if (a_array[i] === b_array[ii]) { tmp_f = false; break; } } if (tmp_f) {my_result.push(a_array[i])} } return my_result; }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.