Revision: 17008
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at August 20, 2009 13:21 by quickredfox
Initial Code
/*
Author: Francois Lafortune (@quickredfox)
License: WTFPL
Description:
Detect if an object exists in an array or detect existance of a key in an object
Example:
(code)
var myArray = [ 'red', 'green', 'blue' ];
Detect.inArray( 'red' , myArray) // true
Detect.inArray( 'brown' , myArray) // false
var myObject = {color: 'blue' };
Detect.inObject('color',myObject) // true
Detect.inObject('taste',myObject) // false
(end)
*/
var Detect = (function() {
var Detect = {
inArray: function(key, array) {
return (key in array);
},
inObject: function(key, object) {
return (key.toString() in object)
}
}
return Detect;
})();
Initial URL
Initial Description
Detect if an object exists in an array or detect existance of a key in an object
Initial Title
Array/Object Detection
Initial Tags
object, array
Initial Language
JavaScript