Some algorithms implementation by JavaScript