Friday, 21 September 2012

How to check array contains element or not

/**
 * This method to check array contains element or not
 * @param array
 * @param element
 * @returns {Boolean}
 */

function contains(array, element) {
    for ( var indx = 0; indx < array.length; indx++) {
        if (array[indx] == element) {
            return true;
        }
    }
    return false;
}

No comments:

Post a Comment

Thank You for your valuable comment

Difference between class level and object locking and static object lock

1) Class level locking will lock entire class, so no other thread can access any of other synchronized blocks. 2) Object locking will lo...