Well first i'd like to point out, please do not use user agent sniffing any more, it is highly frowned upon these days.
See This link for more info why UA sniffing is bad
Answer to your question:
It will work if you declare the getUserAgent method before the isIE method.
var Browsertest = {
getUserAgent: function() {
return navigator.userAgent;
},
isIE: /MSIE (\d+\.\d+)/.test(this.getUserAgent())
};
This is because:
/MSIE (\d+\.\d+)/.test(this.getUserAgent())
Is immediately executed when it is parsed, because it is an expression, not a function declaration. Therefore it does not know about getUserAgent, because that method has simply not yet been parsed.
But the method getUserAgent is redundant, so you could also write it like this:
var Browsertest = {
isIE: /MSIE (\d+\.\d+)/.test(navigator.userAgent)
};