capitalizeKeys
Convert the first letter of each object key to uppercase.
Usage
var capitalizeKeys = require( '@stdlib/utils/capitalize-keys' );
capitalizeKeys( obj )
Converts the first letter of each object
key to uppercase, mapping the transformed keys to a new object
having the same values.
var obj1 = {
'beepBoop': 1,
'fooBar': 2
};
var obj2 = capitalizeKeys( obj1 );
// returns { 'BeepBoop': 1, 'FooBar': 2 }
Notes
- The function only transforms own properties. Hence, the function does not transform inherited properties.
- The function shallow copies key values.
Examples
var capitalizeKeys = require( '@stdlib/utils/capitalize-keys' );
var obj1 = {
'aa': 'beep',
'bb': 'boop',
'cc': 'foo',
'dd': 'bar'
};
var obj2 = capitalizeKeys( obj1 );
console.dir( obj2 );
// => { 'Aa': 'beep', 'Bb': 'boop', 'Cc': 'foo', 'Dd': 'bar' }