Reputation: 216
So this one honestly has me scratching my head. I have a single line of code in my Javascript that does not work when deployed to our test server, but works just fine when run locally from Visual Studio. There's also no problems when running the function in Chrome, regardless of location. It's just a simple line to get the last character of a string, so it's really confusing me why it just stopped working. I'm running IE8 both locally and on the test server (Same machine is browsing, just moved the host).
WhichCredit = WhichCredit[WhichCredit.length - 1];
Upvotes: 3
Views: 171
Reputation: 168853
It may be in the same browser, but are you certain it's displaying in the same mode in both instances?
Is it possible that it's displaying in IE7 compatibility mode in one case? this would make it run an older version of the JS interpreter (among other things), which could cause the kind of effect you're seeing. To check this, open Dev Tools (F12).
Hope that helps.
Upvotes: 3
Reputation: 5049
Accessing characters of a string using bracket notation was introduced in ECMAScript 5. It's possible that the javascript interpreter is old and doesn't support grabbing characters from a string using bracket notation. You'd be far better off using a built-in function, such as WhichCredit.substr(-1)
or WhichCredit.charAt(WhichCredit.length - 1)
to do this.
Upvotes: 5