PHP's array_diff in JavaScript
Feedback


Use JSDoc comment style for the function, this style is widely used and most developers understand it.
Add comments inside your function to describe what every variable is used for and what every section is doing.
Do all the validations before starting to compute the result. So instead of checking if the elements are numbers while constructing the result; you should check them before.
Whenever you find yourself doing something twice, extract it to a separate function.
Throwing an error when it happens is more useful then returning null, it will give the user of your code a hint about what is going wrong and stops the execution of the code instead of using null as an array or checking the result every time your function is called.


Refactored code

/**
 * Checks if the given argument is an integer or not.
 * @param  {Mixed}   n the argument to check
 * @return {Boolean}   TRUE if n is an integer; FALSE otherwise.
 */
function isInteger (n) {
    return !isNaN(n) &amp;&amp; typeof n === 'number' &amp;&amp; n % 1 === 0;
}

/**
 * Checks if the given argument is an array of integers.
 * @param  {Mixed}  array the argument to check.
 * @return {Boolean} TRUE if the given array is an array of integers 
 *                   (or an empty array); FALSE otherwise.
 */
function isArrayOfIntegers (array) {
    return Array.isArray(array) &amp;&amp; array.length == array.filter(isInteger).length;
}

/**
 * Gets an object in which the keys are the items of the given array 
 * and the values are TRUE.
 * @param  {Array} array Array of simple elemets (numbers or strings)
 * @return {Object}
 */
function toIndex (array) {
    return array.reduce(function(index, value) {
        index[value] = true;
        return index;
    }, {});
}

/**
 * Gets the array of elemets which are present exclusively in one of the arrays.
 * @param  {Array} array1 First array of integers.
 * @param  {Array} array2 Second array of integers.
 * @return {Array} Array of the integers which are present 
 *                 exclusively in one of the two arrays.
 * @throws {Error} If one of the two arguments is not an array of integers.
 */
function getArrayDiff (array1, array2) {
    // Validating the arrays
    if (!isArrayOfIntegers(array1) || !isArrayOfIntegers(array2)) {
        throw Error('One of the given parameters is not an array of integers');
    }

    // Making objects from the arrays. Objects in which the keys
    // are the values of the arrays which will allow to search 
    // the elements in logarithmic time
    var index1 = toIndex(array1); 
    var index2 = toIndex(array2);

    // Computing the union of the arrays
    var result = array1.concat(array2);

    // Removing elements which are present in the two arrays
    result = result.filter(function(item){
        return index1[item] === undefined || index2[item] === undefined;
    });

    return result;
}


Hope this will help you and waiting for other members to give their suggestions and improve this code.