Detect and eliminate stray commas in Javascript