Jslint should actually be complaining about this, since prev is not defined. Initialize it to null.