I originally added this to Wikipedia’s Luhn algorithm page but one of their editors deemed there to be too many language implementations, and so they scrubbed it.
I’m posting it here for other PHP programmers, this might save you a few minutes work.
Read the rest of this entry »
As of Javascript 1.6 indexOf()
is a method available for use with Arrays
. However, there’s one subtle difference when operating on a String
and an Array
, both are case sensitive, Array.indexOf()
is type sensitive. This is documented but for those of you who’ve not bothered with the documentation, and it’s not working as expected, here’s a heads up on a subtle gotcha …
Read the rest of this entry »
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's Blog";
alert(name.substr(7, 4)); // Blog
alert(name.substring(7, 11)); // Blog
Minor but caught me out this afternoon.