Object.getValueKey >= 0.1.0

Purpose

Get the key of a value in an array or object

Syntax

Object.getValueKey ( Objecttarget value );

Parameters

target
value

Return values

String

The key, if found in an object

Number

The index, if found in an array

Boolean

False, if not found

Examples

Find a value in an object

var obj = {
    a : 1,
    b : 2,
    c : 3
};

Object.getValueKey(obj, 1);>>> "a"

Object.getValueKey(obj, 999);>>> false

Find a value in an array

var arr = [1, 2, 3];

Object.getValueKey(arr, 1);>>> 0

Object.getValueKey(arr, 999);>>> false