If you need to validate multiple extensions:
var filename = "picture.jpg";
var valid_extensions = /(\.jpg|\.jpeg|\.gif)$/i;
if(valid_extensions.test(filename))
{
alert('OK');
}
else
{
alert('Invalid File');
}
This eliminates the need to parse the string if you want to check the extension, for example, before uploading a file.