##Object Functions
clone
####Example
var original = { foo: 'bar', baz: ['quux'] },
clone = j.clone(original),
shallowCopy = j.clone(original, 0);
JSON.stringify(original) === JSON.stringify(clone); // true
original === clone; // false
original.baz === clone.baz; // false
original === shallowCopy; // false
original.baz === shallowCopy.baz; // true
getKeys
####Example
var myObj = { foo: 'foo', bar: 'bar' };
j.getKeys(myObj); // ['foo', 'bar']
j.getKeys('Bloop!'); // []
j.getKeys(null); // []
merge
####Example
var defaultData = {
1: 'foo',
2: 'bar',
3: 'baz'
},
mergeData = {
1: 'baz',
3: 'quux'
};
j.merge(defaultData, mergeData);
// {
// 1: 'baz',
// 2: 'bar',
// 3: 'quux'
// }
pick
####Example
j.pick('test1', {
'test1': 'test value 1',
'test2': 'test value 2',
'test3': 'test value 3',
});
//test value 1
j.pick('test1', { 'test2': 'not returned' });
//null
pluck
####Example
j.pluck('test1', {
'test1': 'test value 1',
'test2': 'test value 2',
'test3': 'test value 3',
});
//{ 'test1': 'test value 1' }
pluckKeys
####Example
j.pluckKeys(['test1', 'test3'], {
'test1': 'test value 1',
'test2': 'test value 2',
'test3': 'test value 3',
});
//{ 'test1': 'test value 1', 'test3': 'test value 3' }
transform
####Example
var myObj = {
test: 'bar',
bar: {
value: 'bar',
baz: {
value: 'quux'
}
}
},
newObj = j.transform([['test', 'foo'], ['bar.baz', 'baz']], myObj);
JSON.stringify(newObj); // {"foo":"bar","baz":"quux"}