Object.hasValue >= 0.1.0
Purpose
Check if the value exists in an object or array
Syntax
Object.hasValue
(
Objecttarget
value
);
Parameters
target
- The object to search in
value
- The value to look for
Return values
Boolean
Examples
Look for a value in an object
var obj = {
a : 1,
b : 2,
c : 3
};
Object.hasValue(obj, 1);>>> true
Object.hasValue(obj, 4);>>> false
Look for a value in an array
var arr = [0, 1, 2];
Object.hasValue(arr, 1);>>> true
Object.hasValue(arr, 4);>>> false
Comments