I have this code in my Sharepoint app:
function upsertPostTravelListItemTravelerInfo1() {
var clientContext = SP.ClientContext.get_current();
var oList = clientContext.get_web().get_lists().getByTitle('PostTravelFormFields');
this.website = clientContext.get_web();
currentUser = website.get_currentUser();
var commonEffluvia = 'i:0#.f|smp|';
if (currentUser.indexOf(commonEffluvia) > -1) {
currentUser = currentUser.substr(commonEffluvia.length, currentUser.length - commonEffluvia.length);
}
. . .
The reduction of currentUser is necessary because for some reason it often returns 'i:0#.f|smp|' + the user's email address, such as ''i:0#.f|smp|clayshan@ucsc.edu' rather than simply 'clayshan@ucsc.edu'
This code works just dandy in jsfiddle, as evidenced in my fiddle faddle here, but in the code above, running in Chrome, I see, 'Uncaught TypeError: currentUser.indexOf is not a function'
Why does a Javascript method recognized by jsfiddle go unrecognized by Chrome, or Sharepoint (or "whoever" the problem is)?