Javascript sub string nuances
I’m surprised I’ve not run into this before but Javascript has two sub string methods.
[String].substr(start, length); [String].substring(indexA, indexB);
To clarify by example:
var name = "Greg Knapp"; alert(name.substr(5, 5)); // Knapp alert(name.substring(5, 10)); // Knapp
Minor but caught me out this afternoon.
This entry was posted on Wednesday, 25th November, 2009 at 16:17 and is filed under JavaScript, Tech Talk.
You can follow any responses to this entry through the RSS 2.0 feed.
You can skip to the end and leave a response. Pinging is currently not allowed.
You can skip to the end and leave a response. Pinging is currently not allowed.


