rito1
asked on
Javascript TypeError: 'undefined' is not an object (evaluating...
Hi All,
Can anyone help with the school boy error please... I have declared a new object and then return stuff for the property from the function _Mgt_TrackCurrentSessionLo calStorage Management ().
Now, I know there isn't anything to return currently so I believe the object _Mgt_TrackSession should be undefined.
Can anyone see why it would trip up which creating the first property of my object?
Error:
TypeError: 'undefined' is not an object (evaluating '_Mgt_TrackSession.A = intAppID')
Can anyone help with the school boy error please... I have declared a new object and then return stuff for the property from the function _Mgt_TrackCurrentSessionLo
Now, I know there isn't anything to return currently so I believe the object _Mgt_TrackSession should be undefined.
Can anyone see why it would trip up which creating the first property of my object?
_Mgt_TrackSession = new Object();
_Mgt_TrackSession = _Mgt_TrackCurrentSessionLocalStorageManagement("get");
if (typeof(_Mgt_TrackSession) === 'undefined')
{
_Mgt_TrackSession.A = intAppID;
_Mgt_TrackSession.U = intUserID;
_Mgt_TrackSession.P = [];
}
Error:
TypeError: 'undefined' is not an object (evaluating '_Mgt_TrackSession.A = intAppID')
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I believe so, b/c the _Mgt_TrackSession is set to whatever the function returns, so if the function returns nothing (undefined), _Mgt_TrackSession's value is then undefined, not the object you originally instantiated it as.
ASKER
Perfect, thank you for your time.
ASKER
I didn't think I would have to declare it again but it does make sense.. On some occasions my function will return an object for _Mgt_TrackSession. So if there is nothing to return I will need to instantiate it again.. Is that right?