I am getting the error "Can't convert undefined to object on the line return hasOwnProperty(prop);
and I simply cannot figure out where the problem lies. I can post more of the code if necessary.
getCardProperty : function (card, prop, def) {
if (typeof def === "undefined") {
def = null;
}
// json synckolab object
if (card.synckolab) {
if (card.hasOwnProperty(prop)) // TODO better check for undefined?
{
return hasOwnProperty(prop);
}
return null;
}
hasOwnProperty(prop)
doesn't exist - you need to qualify it with an object name. Just change it to card.hasOwnProperty(prop)
.
You can simplify it further:
if (card.synckolab) {
return card.hasOwnProperty(prop) || null;
}
This will return true
or null
. Or you can simplify even further:
if (card.synckolab) {
return card.hasOwnProperty(prop);
}
This will return true
or false
.