How to detect double and single clicks using javascript?

Hi , I am trying to detect if a button is double clicked or single clicked , I have searched for an answer but the code I’m using at the moment always performs the single click code because the double click is made up of two single clicks. Sorry if this is badly worded , any help on the topic is very helpful =) Cheers.

“use this to differentiate between a single and double clicks”