Return to Snippet

Revision: 51761
at October 4, 2011 03:44 by vaibhav011286


Initial Code
function in_array(d, b, a) {
	var c = "", a = !! a;
	for (c in b) if (a && b[c] === d) return !0;
	else if (!a && b[c] == d) return !0;
	return !1
};

    // *     example 1: in_array('van', ['Kevin', 'van', 'Zonneveld']);    // *     returns 1: true
    // *     example 2: in_array('vlado', {0: 'Kevin', vlado: 'van', 1: 'Zonneveld'});
    // *     returns 2: false
    // *     example 3: in_array(1, ['1', '2', '3']);
    // *     returns 3: true    // *     example 3: in_array(1, ['1', '2', '3'], false);
    // *     returns 3: true
    // *     example 4: in_array(1, ['1', '2', '3'], true);

Initial URL
http://phpjs.org/functions/in_array:432

Initial Description

                                

Initial Title
Minimized JS in_array() function

Initial Tags
javascript

Initial Language
JavaScript