I have an object in JavaScript:
var obj = {
"a": "test1",
"b": "test2"
}
How do I check that te
getValue = function (object, key) {
return key.split(".").reduce(function (obj, val) {
return (typeof obj == "undefined" || obj === null || obj === "") ? obj : (_.isString(obj[val]) ? obj[val].trim() : obj[val]);}, object);
};
var obj = {
"a": "test1",
"b": "test2"
};
Function called:
getValue(obj, "a");