Javascript derivative taker