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 tocard.hasOwnProperty(prop).You can simplify it further:
This will return
trueornull. Or you can simplify even further:This will return
trueorfalse.