Tuesday, December 10, 2013

in_array function in javascript

This is a simple post for the converted in_array function in javascript. This function will return boolean whether the value is in the array or not.

function in_array(array, id) {
    for(var i=0; i<array.length; i++) {
        if (array[i]==id) return true;
    }
    return false;
}



Hope you like this post, probably short but will help a lot.

No comments:

Post a Comment