javascript - How can I find the length of a specific index in an array -


have tried various things

split[6].length string.split[6].length 

along these lines without success error message last 1 ...

referenceerror: "string" not defined.

hi replies, in end created array based on index of original array , queried length of that. can see having trouble removing single , double quotes input strings. new javascript , making me little crazy lol.

// loop through input messages (var = 0; < input.length; i++) {     var next = output.append(input[i]); // body of current input message var body = input[i].text; // set body next.text = body ; next.text.replace(/\'/g, "&#39;"); next.text.replace(/\"/g, "&#34;"); //replace(/['"]/g,''); // set property     var split = next.text.split(",");        var array1 = split[5]; var array2 = split[2]; next.setproperty("aaalength", split.length); next.setproperty("aaasplitvalue", split.length);   next.setproperty("aaaarray1value", split.length);  next.setproperty("aaaarray2value", split.length);  if (next.getproperty("basefilename")=="name"){     next.text.replace(/\'/g, "&#39;");     next.text.replace(/\"/g, "&#34;");     //replace(/['"]/g,'');     if(split.length>10){          next.setproperty("fullfilename","nameerror"+i);         next.setproperty("basefilename","nameerror"+i);         next.setproperty("suffix",".err");          }         if(array1.length>10){             next.setproperty("fullfilename","namesnamesuffixerror"+i);             next.setproperty("basefilename","namesnamesuffixerror"+i);             next.setproperty("suffix",".err");               } } 

length should work if elements strings. see following in action @ http://jsfiddle.net/46njw/

var parts = "foo,bar,baz,foop".split(/,/); alert( parts[3].length ); // should alert 4 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -