Look at the source code to see how it is implemented in Javascript.