lowercaseKeys

    Convert each object key to lowercase.

    Usage

    var lowercaseKeys = require( '@stdlib/utils/lowercase-keys' );
    

    lowercaseKeys( obj )

    Converts each object key to lowercase, mapping the transformed keys to a new object having the same values.

    var obj1 = {
        'A': 1,
        'B': 2
    };
    
    var obj2 = lowercaseKeys( obj1 );
    // returns { 'a': 1, 'b': 2 }
    

    Notes

    • The function only transforms own properties. Hence, the function does not transform inherited properties.
    • The function shallow copies key values.

    Examples

    var lowercaseKeys = require( '@stdlib/utils/lowercase-keys' );
    
    var obj1 = {
        'A': 'beep',
        'B': 'boop',
        'C': 'foo',
        'D': 'bar'
    };
    
    var obj2 = lowercaseKeys( obj1 );
    
    console.dir( obj2 );
    // => { 'a': 'beep', 'b': 'boop', 'c': 'foo', 'd': 'bar' }