0

Hello I have next JS code (this code not my own)

 function somename(f) 
    var procName = "";
    var procParams = new Array();
    var parseEl = "";
    var parseEls = new Array();
    var parseInd = 0;
    var procParamsInd = 0;
    var IsValRead = false;
    for (i = 0; i < f.length; i++) {
        if (f[i] == "(")
            break;
        else
            procName = procName + f[i];
    }

}

I will redo it to much better way to find data before "(", but i wounder why procName variable is always undefined in IE9 in all browsers all working well.

7
  • 1
    please show the actual error. Commented May 18, 2012 at 12:44
  • Works for me in the IE9 developer console Commented May 18, 2012 at 12:52
  • procName is undefined in for loop. and result is like undefinedundefinedundefinedundefined Commented May 18, 2012 at 12:54
  • Is procName undefined or f[x]? Commented May 18, 2012 at 13:16
  • 1
    I have a vague recollection that at least some versions of IE do not support indexing to access string characters. Try using charAt instead; or a better algorithm. It is almost certainly the f[x] which is causing your undefined's. Commented May 18, 2012 at 13:54

2 Answers 2

1

I have a vague recollection that at least some versions of IE do not support indexing to access string characters. Try using charAt instead; or a better algorithm. It is almost certainly the f[x] which is causing your undefined's.

Sign up to request clarification or add additional context in comments.

Comments

1

A better way to get the substring before ( is this:

var f = "name(2,4,5)",
    procName = f.slice(0, f.indexOf('(')); //slice from start until before "("

console.log(procName)​; //name

1 Comment

Thanks this is nice. but question was about why procName is undefined in for.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.