Q:

cannot get string length in javascript

Over 1 hour on this.  This is javascript code inside my index.php file.
function dostuff()
{

   var thepath = document.location.search.substring(1);
   alert('the path is ' + thepath + " (that's the full path)");
   alert(thepath);

       // TRIED THESE ALL -- NONE OF THEM WORK.
   //var pathLen = String.length("thepath");
   //var pathLen = String.length(thepath);
   //var pathLen = thepath.length();
   var pathLen = String.length(document.location.search.substring(1));
   alert('pathLen is ' + pathLen);
}

The symptom: the first 2 alert boxes appear no problem and both show 'thepath' has a valid pathname in it, and it is the correct, expected path too.
But no matter what I try -- see the 4 different attempts, tried one at a time -- the final alert() box NEVER shows up.
Why is  alert('pathLen is ' + pathLen)  not showing up?
(The other thing is -- I'm using XDEBUG and xampp and Netbeans and the debugger will not let me put a breakpoint in this javascript code, so I can't even step into it to see what's happening, hence the use of the alert()'s in the code.  I know the XDEBUG debugger I'm using in Netbeans works -- I've been using it all night to debug PHP code in a different.PHP file.  When I set a breakpoint though in any Javascript code, a 'broken breakpoint' icon appears and I cannot find what that means in Netbeans documentation.)

A:

I've never seen that syntax before. You might want to try:
var pathLen = thepath.length;

(You'd be best off debugging with Firebug)

A:

var pathLen = thepath.length;

Length is a property of the string, not a function, so no need for the ().

