Link to home
Start Free TrialLog in
Avatar of rito1
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_TrackCurrentSessionLocalStorageManagement().

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 = [];
}

Open in new window



Error:


TypeError: 'undefined' is not an object (evaluating '_Mgt_TrackSession.A = intAppID')
ASKER CERTIFIED SOLUTION
Avatar of onlyaymie
onlyaymie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rito1
rito1

ASKER

Thanks onlyaymi, I will give this a try as soon as I get in the office in the morning GMT.

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?
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.
Avatar of rito1

ASKER

Perfect, thank you for your time.