Return to Snippet

Revision: 38348
at December 31, 2010 08:31 by cornellsteven


Updated Code
function in_array(needle, haystack) {
	for (var i=0, j=haystack.length; i < j; i++) {
		if (needle == haystack[i]) return true;
	}
	return false;
}

Revision: 38347
at December 31, 2010 08:25 by cornellsteven


Updated Code
function in_array(needle, haystack) {
	for (var i=0, var j=haystack.length; i < j; i++) {
		if (needle == haystack[i]) return true;
	}
	return false;
}

Revision: 38346
at December 31, 2010 08:24 by cornellsteven


Initial Code
function in_array(needle, haystack) {
	for (var i=0; i < haystack.length; i++) {
		if (needle == haystack[i]) return true;
	}
	return false;
}

Initial URL

                                

Initial Description
Quick and easy javascript in_array function. It's not perfect, but if you need something quick, this is it.

Initial Title
javascript in_array

Initial Tags
javascript, array

Initial Language
JavaScript