user2917629
user2917629

Reputation: 942

JavaScript error anonymous function

I have something like this

if(window.Test==null)
{
    window.Test = {};
    Test.usrTZ = Test.getTZ( new Date().getTimezoneOffset() );

    Test.getTZ = function(offset)
    {
     .....
     return offset;
    };

}

The line Test.usrTZ = Test.getTZ( new Date().getTimezoneOffset() ); throws in Chrome an error "Uncaught TypeError: undefined is not a function". I in general use traditional object notation, but want to learn how to use this one. I'm not sure what I'm doing wrong here - any help is much appreciated!

Upvotes: 0

Views: 1496

Answers (1)

Evan Davis
Evan Davis

Reputation: 36592

You are calling Test.getTZ before you have defined it.

Upvotes: 3

Related Questions