I have had object
dataSourceConfig.transport.read.url
remoteDataSourceConfig: {
transport: {
read: {
url: null,
},
},
},
How to check dataSourceConfig.transport.read.url
for undefiend?
I have had object
dataSourceConfig.transport.read.url
remoteDataSourceConfig: {
transport: {
read: {
url: null,
},
},
},
How to check dataSourceConfig.transport.read.url
for undefiend?
If I understand your question crrectly, you have to check all the intermediary objects for existence:
if (dataSourceConfig &&
dataSourceConfig.transport &&
dataSourceConfig.transport.read &&
dataSourceConfig.transport.read.url != null
) {
// is not null or undefined
}
Otherwise you can do something like this:
function isKeySet(obj, key) {
var keys = key.split('.');
return keys.reduce(function(o,k){ return o[k]; }, obj) != null;
}
isKeySet(dataSourceConfig, 'transport.read.url'); // false